Search in sources :

Example 1 with LogEntry

use of org.apache.airavata.common.logging.LogEntry 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)

Aggregations

IThrowableProxy (ch.qos.logback.classic.spi.IThrowableProxy)1 Gson (com.google.gson.Gson)1 Exception (org.apache.airavata.common.logging.Exception)1 LogEntry (org.apache.airavata.common.logging.LogEntry)1