use of org.apache.log4j.spi.ThrowableInformation in project ChatGameFontificator by GlitchCog.
the class DebugAppender method append.
@Override
public void append(LoggingEvent event) {
debugLogBox.log(this.layout.format(event));
ThrowableInformation info = event.getThrowableInformation();
if (info != null && info.getThrowable() != null) {
Throwable t = info.getThrowable();
debugLogBox.log(throwableToString(t));
}
}
use of org.apache.log4j.spi.ThrowableInformation in project hadoop by apache.
the class Log4Json method toJson.
/**
* Convert an event to JSON
*
* @param writer the destination writer
* @param event the event -must not be null
* @return the writer
* @throws IOException on problems generating the JSON
*/
public Writer toJson(final Writer writer, final LoggingEvent event) throws IOException {
ThrowableInformation ti = event.getThrowableInformation();
toJson(writer, event.getLoggerName(), event.getTimeStamp(), event.getLevel().toString(), event.getThreadName(), event.getRenderedMessage(), ti);
return writer;
}
use of org.apache.log4j.spi.ThrowableInformation in project ats-framework by Axway.
the class DbEventRequestProcessor method getLoggingMesage.
private String getLoggingMesage(LoggingEvent event) {
Throwable throwable = null;
ThrowableInformation throwableInfo = event.getThrowableInformation();
if (throwableInfo != null && throwableInfo.getThrowable() != null) {
// logging through methods like error(new Exception);
throwable = throwableInfo.getThrowable();
} else if (event.getMessage() instanceof Throwable) {
// logging through methods like error("some message", new Exception);
throwable = (Throwable) event.getMessage();
}
// first format the message using the layout
String message = layout.format(event);
// then append the exception stack trace
if (throwable != null) {
message = getExceptionMsg(throwable, message);
}
return message;
}
use of org.apache.log4j.spi.ThrowableInformation in project intellij-community by JetBrains.
the class DialogAppender method appendToLoggers.
void appendToLoggers(@NotNull LoggingEvent event, @NotNull ErrorLogger[] errorLoggers) {
if (myDialogRunnable != null) {
return;
}
final IdeaLoggingEvent ideaEvent;
final Object message = event.getMessage();
if (message instanceof IdeaLoggingEvent) {
ideaEvent = (IdeaLoggingEvent) message;
} else {
ThrowableInformation info = event.getThrowableInformation();
if (info == null) {
return;
}
ideaEvent = extractLoggingEvent(message, info.getThrowable());
}
for (int i = errorLoggers.length - 1; i >= 0; i--) {
final ErrorLogger logger = errorLoggers[i];
if (!logger.canHandle(ideaEvent)) {
continue;
}
myDialogRunnable = () -> {
try {
logger.handle(ideaEvent);
} finally {
myDialogRunnable = null;
}
};
final Application app = ApplicationManager.getApplication();
if (app == null) {
new Thread(myDialogRunnable, "dialog appender logger").start();
} else {
app.executeOnPooledThread(myDialogRunnable);
}
break;
}
}
use of org.apache.log4j.spi.ThrowableInformation in project lucene-solr by apache.
the class SolrLogLayout method _format.
public String _format(LoggingEvent event) {
String message = (String) event.getMessage();
if (message == null) {
message = "";
}
StringBuilder sb = new StringBuilder(message.length() + 80);
long now = event.timeStamp;
long timeFromStart = now - startTime;
long timeSinceLast = now - lastTime;
lastTime = now;
String shortClassName = getShortClassName(event.getLocationInformation().getClassName(), event.getLocationInformation().getMethodName());
/***
* sb.append(timeFromStart).append(' ').append(timeSinceLast);
* sb.append(' ');
* sb.append(record.getSourceClassName()).append('.').append(
* record.getSourceMethodName()); sb.append(' ');
* sb.append(record.getLevel());
***/
SolrRequestInfo requestInfo = SolrRequestInfo.getRequestInfo();
SolrQueryRequest req = requestInfo == null ? null : requestInfo.getReq();
SolrCore core = req == null ? null : req.getCore();
ZkController zkController = null;
CoreInfo info = null;
if (core != null) {
info = coreInfoMap.get(core.hashCode());
if (info == null) {
info = new CoreInfo();
info.shortId = "C" + Integer.toString(CoreInfo.maxCoreNum++);
coreInfoMap.put(core.hashCode(), info);
if (sb.length() == 0)
sb.append("ASYNC ");
sb.append(" NEW_CORE " + info.shortId);
sb.append(" name=" + core.getName());
sb.append(" " + core);
}
zkController = core.getCoreContainer().getZkController();
if (zkController != null) {
if (info.url == null) {
info.url = zkController.getBaseUrl() + "/" + core.getName();
sb.append(" url=" + info.url + " node=" + zkController.getNodeName());
}
Map<String, Object> coreProps = getReplicaProps(zkController, core);
if (info.coreProps == null || !coreProps.equals(info.coreProps)) {
info.coreProps = coreProps;
final String corePropsString = "coll:" + core.getCoreDescriptor().getCloudDescriptor().getCollectionName() + " core:" + core.getName() + " props:" + coreProps;
sb.append(" " + info.shortId + "_STATE=" + corePropsString);
}
}
}
if (sb.length() > 0)
sb.append('\n');
sb.append(timeFromStart);
// sb.append("\nL").append(record.getSequenceNumber()); // log number is
// useful for sequencing when looking at multiple parts of a log file, but
// ms since start should be fine.
appendThread(sb, event);
appendMDC(sb);
if (info != null) {
// core
sb.append(' ').append(info.shortId);
}
if (shortClassName.length() > 0) {
sb.append(' ').append(shortClassName);
}
if (event.getLevel() != Level.INFO) {
sb.append(' ').append(event.getLevel());
}
sb.append(' ');
appendMultiLineString(sb, message);
ThrowableInformation thInfo = event.getThrowableInformation();
if (thInfo != null) {
Throwable th = event.getThrowableInformation().getThrowable();
if (th != null) {
sb.append(' ');
String err = SolrException.toStr(th);
String ignoredMsg = SolrException.doIgnore(th, err);
if (ignoredMsg != null) {
sb.append(ignoredMsg);
} else {
sb.append(err);
}
}
}
sb.append('\n');
return sb.toString();
}
Aggregations