use of ch.qos.logback.classic.spi.IThrowableProxy in project airavata by apache.
the class KafkaAppender method append.
@Override
protected void append(ILoggingEvent event) {
event.prepareForDeferredProcessing();
if (// OFF AND ALL are not loggable levels
!event.getLevel().equals(Level.ALL) && !event.getLevel().equals(Level.OFF)) {
final IThrowableProxy throwableProxy = event.getThrowableProxy();
final LogEntry entry = throwableProxy != null ? new LogEntry(serverId, event.getFormattedMessage(), Instant.ofEpochMilli(event.getTimeStamp()).toString(), event.getLevel().toString(), event.getLoggerName(), event.getMDCPropertyMap(), event.getThreadName() != null ? event.getThreadName() : null, new Exception(throwableProxy.getMessage(), toStringArray(throwableProxy.getStackTraceElementProxyArray()), throwableProxy.getClassName())) : new LogEntry(serverId, event.getFormattedMessage(), Instant.ofEpochMilli(event.getTimeStamp()).toString(), event.getLevel().toString(), event.getLoggerName(), event.getMDCPropertyMap(), event.getThreadName() != null ? event.getThreadName() : null);
producer.send(new ProducerRecord<>(kafkaTopic, new Gson().toJson(entry)));
}
}
use of ch.qos.logback.classic.spi.IThrowableProxy in project cdap by caskdata.
the class ThrowableProxySerializer method decode.
static IThrowableProxy decode(GenericRecord datum) {
if (datum != null) {
String className = LoggingUtil.stringOrNull(datum.get("className"));
String message = LoggingUtil.stringOrNull(datum.get("message"));
int commonFramesCount = (Integer) datum.get("commonFramesCount");
@SuppressWarnings("unchecked") StackTraceElementProxy[] steArray = StackTraceElementProxyArraySerializer.decode((GenericArray<GenericRecord>) datum.get("stackTraceElementProxyArray"));
IThrowableProxy cause = ThrowableProxySerializer.decode((GenericRecord) datum.get("cause"));
@SuppressWarnings("unchecked") IThrowableProxy[] suppressed = ThrowableProxyArraySerializer.decode((GenericArray<GenericRecord>) datum.get("suppressed"));
return new ThrowableProxyImpl(cause, className, commonFramesCount, message, steArray, suppressed);
}
return null;
}
use of ch.qos.logback.classic.spi.IThrowableProxy in project xian by happyyangyuan.
the class LogbackLogEvent method getThrowable.
@Override
public Throwable getThrowable() {
Throwable result = null;
IThrowableProxy throwableProxy = loggingEvent.getThrowableProxy();
if (null != throwableProxy) {
if (throwableProxy instanceof ThrowableProxy) {
result = ((ThrowableProxy) throwableProxy).getThrowable();
}
}
return result;
}
use of ch.qos.logback.classic.spi.IThrowableProxy in project cassandra by apache.
the class LogbackFilter method decide.
public FilterReply decide(Object o) {
if (!(o instanceof LoggingEvent))
return FilterReply.NEUTRAL;
LoggingEvent e = (LoggingEvent) o;
// if (ignore.matcher(e.getMessage()).find())
// return FilterReply.DENY;
IThrowableProxy t = e.getThrowableProxy();
if (t == null)
return FilterReply.NEUTRAL;
if (!isIntentional(t))
return FilterReply.NEUTRAL;
// logger.info("Filtered exception {}: {}", t.getClassName(), t.getMessage());
return FilterReply.DENY;
}
use of ch.qos.logback.classic.spi.IThrowableProxy in project sonarqube by SonarSource.
the class LogbackJsonLayout method doLayout.
@Override
public String doLayout(ILoggingEvent event) {
StringWriter output = new StringWriter();
try (JsonWriter json = new JsonWriter(output)) {
json.beginObject();
if (!"".equals(nodeName)) {
json.name("nodename").value(nodeName);
}
json.name("process").value(processKey);
for (Map.Entry<String, String> entry : event.getMDCPropertyMap().entrySet()) {
if (entry.getValue() != null) {
json.name(entry.getKey()).value(entry.getValue());
}
}
json.name("timestamp").value(DATE_FORMATTER.format(Instant.ofEpochMilli(event.getTimeStamp()))).name("severity").value(event.getLevel().toString()).name("logger").value(event.getLoggerName()).name("message").value(NEWLINE_REGEXP.matcher(event.getFormattedMessage()).replaceAll("\r"));
IThrowableProxy tp = event.getThrowableProxy();
if (tp != null) {
json.name("stacktrace").beginArray();
int nbOfTabs = 0;
while (tp != null) {
printFirstLine(json, tp, nbOfTabs);
render(json, tp, nbOfTabs);
tp = tp.getCause();
nbOfTabs++;
}
json.endArray();
}
json.endObject();
} catch (Exception e) {
e.printStackTrace();
throw new IllegalStateException("BUG - fail to create JSON", e);
}
output.write(System.lineSeparator());
return output.toString();
}
Aggregations