Search in sources :

Example 1 with IThrowableProxy

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)));
    }
}
Also used : IThrowableProxy(ch.qos.logback.classic.spi.IThrowableProxy) Gson(com.google.gson.Gson) LogEntry(org.apache.airavata.common.logging.LogEntry) Exception(org.apache.airavata.common.logging.Exception)

Example 2 with IThrowableProxy

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;
}
Also used : IThrowableProxy(ch.qos.logback.classic.spi.IThrowableProxy) GenericRecord(org.apache.avro.generic.GenericRecord) StackTraceElementProxy(ch.qos.logback.classic.spi.StackTraceElementProxy)

Example 3 with IThrowableProxy

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;
}
Also used : IThrowableProxy(ch.qos.logback.classic.spi.IThrowableProxy) IThrowableProxy(ch.qos.logback.classic.spi.IThrowableProxy) ThrowableProxy(ch.qos.logback.classic.spi.ThrowableProxy)

Example 4 with IThrowableProxy

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;
}
Also used : LoggingEvent(ch.qos.logback.classic.spi.LoggingEvent) IThrowableProxy(ch.qos.logback.classic.spi.IThrowableProxy)

Example 5 with IThrowableProxy

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();
}
Also used : StringWriter(java.io.StringWriter) IThrowableProxy(ch.qos.logback.classic.spi.IThrowableProxy) JsonWriter(com.google.gson.stream.JsonWriter) Map(java.util.Map) IOException(java.io.IOException)

Aggregations

IThrowableProxy (ch.qos.logback.classic.spi.IThrowableProxy)16 StackTraceElementProxy (ch.qos.logback.classic.spi.StackTraceElementProxy)4 ILoggingEvent (ch.qos.logback.classic.spi.ILoggingEvent)3 GenericRecord (org.apache.avro.generic.GenericRecord)3 ThrowableProxy (ch.qos.logback.classic.spi.ThrowableProxy)2 IOException (java.io.IOException)2 Level (ch.qos.logback.classic.Level)1 LoggingEvent (ch.qos.logback.classic.spi.LoggingEvent)1 Gson (com.google.gson.Gson)1 JsonWriter (com.google.gson.stream.JsonWriter)1 FinishCheck (com.vip.saturn.it.base.FinishCheck)1 SimpleJavaJob (com.vip.saturn.it.job.SimpleJavaJob)1 LogbackListAppender (com.vip.saturn.it.utils.LogbackListAppender)1 JobConfig (com.vip.saturn.job.console.domain.JobConfig)1 StringWriter (java.io.StringWriter)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 Exception (org.apache.airavata.common.logging.Exception)1 LogEntry (org.apache.airavata.common.logging.LogEntry)1 Schema (org.apache.avro.Schema)1