Search in sources :

Example 6 with IThrowableProxy

use of ch.qos.logback.classic.spi.IThrowableProxy in project sonarqube by SonarSource.

the class LogbackJsonLayout method render.

private static void render(JsonWriter output, IThrowableProxy tp, int nbOfTabs) throws IOException {
    String tabs = StringUtils.repeat("\t", nbOfTabs);
    int commonFrames = tp.getCommonFrames();
    StackTraceElementProxy[] stepArray = tp.getStackTraceElementProxyArray();
    for (int i = 0; i < stepArray.length - commonFrames; i++) {
        StackTraceElementProxy step = stepArray[i];
        output.value(tabs + step.toString());
    }
    if (commonFrames > 0) {
        output.value(tabs + "... " + commonFrames + " common frames omitted");
    }
    for (IThrowableProxy suppressed : tp.getSuppressed()) {
        output.value(format("%sSuppressed: %s: %s", tabs, suppressed.getClassName(), suppressed.getMessage()));
        render(output, suppressed, nbOfTabs + 1);
    }
}
Also used : IThrowableProxy(ch.qos.logback.classic.spi.IThrowableProxy) StackTraceElementProxy(ch.qos.logback.classic.spi.StackTraceElementProxy)

Example 7 with IThrowableProxy

use of ch.qos.logback.classic.spi.IThrowableProxy in project pravega by pravega.

the class MetricsLogAppender method recordEvent.

private void recordEvent(String metricName, ILoggingEvent event) {
    IThrowableProxy p = event.getThrowableProxy();
    while (shouldUnwrap(p)) {
        p = p.getCause();
    }
    DYNAMIC_LOGGER.recordMeterEvents(metricName, 1, MetricsTags.exceptionTag(event.getLoggerName(), p == null ? null : p.getClassName()));
}
Also used : IThrowableProxy(ch.qos.logback.classic.spi.IThrowableProxy)

Example 8 with IThrowableProxy

use of ch.qos.logback.classic.spi.IThrowableProxy in project TOSCAna by StuPro-TOSCAna.

the class MemoryAppender method appendThrowable.

private void appendThrowable(IThrowableProxy proxy, ILoggingEvent loggingEvent) {
    // Append Exception Message
    appendToLog(loggingEvent, String.format("%s: %s", proxy.getClassName(), proxy.getMessage()));
    // Append Exception Stack Trace
    for (StackTraceElementProxy element : loggingEvent.getThrowableProxy().getStackTraceElementProxyArray()) {
        appendToLog(loggingEvent, "\t" + element.getSTEAsString());
    }
    if (proxy.getSuppressed().length > 0) {
        appendToLog(loggingEvent, "Suppressed Exceptions:");
        for (IThrowableProxy p : proxy.getSuppressed()) {
            appendThrowable(p, loggingEvent);
        }
    }
    if (proxy.getCause() != null) {
        appendToLog(loggingEvent, "Cause:");
        appendThrowable(proxy.getCause(), loggingEvent);
    }
}
Also used : IThrowableProxy(ch.qos.logback.classic.spi.IThrowableProxy) StackTraceElementProxy(ch.qos.logback.classic.spi.StackTraceElementProxy)

Example 9 with IThrowableProxy

use of ch.qos.logback.classic.spi.IThrowableProxy in project qpid-broker-j by apache.

the class Logback1027WorkaroundTurboFilterTest method assertLoggingEvent.

private void assertLoggingEvent(final ILoggingEvent loggingEvent) {
    assertEquals(Level.INFO, loggingEvent.getLevel());
    assertEquals(TEST_LOG_MESSAGE, loggingEvent.getMessage());
    assertNull(loggingEvent.getArgumentArray());
    IThrowableProxy thing = loggingEvent.getThrowableProxy();
    assertEquals(Logback1027WorkaroundTurboFilter.StringifiedException.class.getName(), thing.getClassName());
}
Also used : IThrowableProxy(ch.qos.logback.classic.spi.IThrowableProxy)

Example 10 with IThrowableProxy

use of ch.qos.logback.classic.spi.IThrowableProxy in project sonarlint-core by SonarSource.

the class LogCallbackAppenderTest method testExceptionHandling.

@Test
public void testExceptionHandling() {
    appender.setErrorHandler(errorHandler);
    reset(listener);
    event = mock(ILoggingEvent.class);
    IThrowableProxy throwable = new ThrowableProxy(new IOException());
    when(event.getThrowableProxy()).thenReturn(throwable);
    when(event.getLevel()).thenReturn(Level.ERROR);
    appender.append(event);
    verify(errorHandler).handleException("java.io.IOException");
}
Also used : IThrowableProxy(ch.qos.logback.classic.spi.IThrowableProxy) IOException(java.io.IOException) ILoggingEvent(ch.qos.logback.classic.spi.ILoggingEvent) IThrowableProxy(ch.qos.logback.classic.spi.IThrowableProxy) ThrowableProxy(ch.qos.logback.classic.spi.ThrowableProxy) Test(org.junit.Test)

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 Map (java.util.Map)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 Exception (org.apache.airavata.common.logging.Exception)1 LogEntry (org.apache.airavata.common.logging.LogEntry)1 Schema (org.apache.avro.Schema)1