org.apache.logging.log4j.core.impl.ThrowableProxy Java Examples

The following examples show how to use org.apache.logging.log4j.core.impl.ThrowableProxy. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JsonSetupContextInitializer.java    From logging-log4j2 with Apache License 2.0 6 votes vote down vote up
public void setupModule(final SetupContext context, final boolean includeStacktrace,
        final boolean stacktraceAsString) {
    // JRE classes: we cannot edit those with Jackson annotations
    context.setMixInAnnotations(StackTraceElement.class, StackTraceElementMixIn.class);
    // Log4j API classes: we do not want to edit those with Jackson annotations because the API module should not
    // depend on Jackson.
    context.setMixInAnnotations(Marker.class, MarkerMixIn.class);
    context.setMixInAnnotations(Level.class, LevelMixIn.class);
    context.setMixInAnnotations(Instant.class, InstantMixIn.class);
    context.setMixInAnnotations(LogEvent.class, LogEventJsonMixIn.class); // different ThreadContext handling
    // Log4j Core classes: we do not want to bring in Jackson at runtime if we do not have to.
    context.setMixInAnnotations(ExtendedStackTraceElement.class, ExtendedStackTraceElementMixIn.class);
    context.setMixInAnnotations(ThrowableProxy.class, includeStacktrace
            ? (stacktraceAsString ? ThrowableProxyWithStacktraceAsStringMixIn.class : ThrowableProxyMixIn.class)
            : ThrowableProxyWithoutStacktraceMixIn.class);
}
 
Example #2
Source File: XmlSetupContextInitializer.java    From logging-log4j2 with Apache License 2.0 6 votes vote down vote up
public void setupModule(final SetupContext context, final boolean includeStacktrace,
        final boolean stacktraceAsString) {
    // JRE classes: we cannot edit those with Jackson annotations
    context.setMixInAnnotations(StackTraceElement.class, StackTraceElementXmlMixIn.class);
    // Log4j API classes: we do not want to edit those with Jackson annotations because the API module should not
    // depend on Jackson.
    context.setMixInAnnotations(Marker.class, MarkerXmlMixIn.class);
    context.setMixInAnnotations(Level.class, LevelMixIn.class);
    context.setMixInAnnotations(Instant.class, InstantXmlMixIn.class);
    context.setMixInAnnotations(LogEvent.class, LogEventWithContextListXmlMixIn.class);
    // Log4j Core classes: we do not want to bring in Jackson at runtime if we do not have to.
    context.setMixInAnnotations(ExtendedStackTraceElement.class, ExtendedStackTraceElementXmlMixIn.class);
    context.setMixInAnnotations(ThrowableProxy.class, includeStacktrace
            ? (stacktraceAsString ? ThrowableProxyWithStacktraceAsStringXmlMixIn.class : ThrowableProxyXmlMixIn.class)
            : ThrowableProxyWithoutStacktraceXmlMixIn.class);
}
 
Example #3
Source File: SetupContextInitializer.java    From logging-log4j2 with Apache License 2.0 6 votes vote down vote up
public void setupModule(final SetupContext context, final boolean includeStacktrace,
        final boolean stacktraceAsString) {
    // JRE classes: we cannot edit those with Jackson annotations
    context.setMixInAnnotations(StackTraceElement.class, StackTraceElementMixIn.class);
    // Log4j API classes: we do not want to edit those with Jackson annotations because the API module should not
    // depend on Jackson.
    context.setMixInAnnotations(Marker.class, MarkerMixIn.class);
    context.setMixInAnnotations(Level.class, LevelMixIn.class);
    context.setMixInAnnotations(Instant.class, InstantMixIn.class);
    context.setMixInAnnotations(LogEvent.class, LogEventWithContextListMixIn.class);
    // Log4j Core classes: we do not want to bring in Jackson at runtime if we do not have to.
    context.setMixInAnnotations(ExtendedStackTraceElement.class, ExtendedStackTraceElementMixIn.class);
    context.setMixInAnnotations(ThrowableProxy.class, includeStacktrace
            ? (stacktraceAsString ? ThrowableProxyWithStacktraceAsStringMixIn.class : ThrowableProxyMixIn.class)
            : ThrowableProxyWithoutStacktraceMixIn.class);
}
 
Example #4
Source File: ExtendedThrowablePatternConverter.java    From logging-log4j2 with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void format(final LogEvent event, final StringBuilder toAppendTo) {
    final ThrowableProxy proxy = event.getThrownProxy();
    final Throwable throwable = event.getThrown();
    if ((throwable != null || proxy != null) && options.anyLines()) {
        if (proxy == null) {
            super.format(event, toAppendTo);
            return;
        }
        final int len = toAppendTo.length();
        if (len > 0 && !Character.isWhitespace(toAppendTo.charAt(len - 1))) {
            toAppendTo.append(' ');
        }
        proxy.formatExtendedStackTraceTo(toAppendTo, options.getIgnorePackages(),
                options.getTextRenderer(), getSuffix(event), options.getSeparator());
    }
}
 
Example #5
Source File: YamlSetupContextInitializer.java    From logging-log4j2 with Apache License 2.0 6 votes vote down vote up
public void setupModule(final SetupContext context, final boolean includeStacktrace,
        final boolean stacktraceAsString) {
    // JRE classes: we cannot edit those with Jackson annotations
    context.setMixInAnnotations(StackTraceElement.class, StackTraceElementMixIn.class);
    // Log4j API classes: we do not want to edit those with Jackson annotations because the API module should not
    // depend on Jackson.
    context.setMixInAnnotations(Marker.class, MarkerMixIn.class);
    context.setMixInAnnotations(Level.class, LevelMixIn.class);
    context.setMixInAnnotations(Instant.class, InstantMixIn.class);
    context.setMixInAnnotations(LogEvent.class, LogEventJsonMixIn.class); // different ThreadContext handling
    // Log4j Core classes: we do not want to bring in Jackson at runtime if we do not have to.
    context.setMixInAnnotations(ExtendedStackTraceElement.class, ExtendedStackTraceElementMixIn.class);
    context.setMixInAnnotations(ThrowableProxy.class, includeStacktrace
            ? (stacktraceAsString ? ThrowableProxyWithStacktraceAsStringMixIn.class : ThrowableProxyMixIn.class)
            : ThrowableProxyWithoutStacktraceMixIn.class);
}
 
Example #6
Source File: RollbarAppenderTest.java    From rollbar-java with MIT License 6 votes vote down vote up
@Test
public void shouldLogEventWhenNoNDC() {
  RollbarThrowableWrapper throwableWrapper = new RollbarThrowableWrapper(EXCEPTION);

  when(event.getLoggerName()).thenReturn(LOGGER_NAME);
  when(event.getMarker()).thenReturn(marker);
  when(event.getThreadName()).thenReturn(THREAD_NAME);
  when(event.getLevel()).thenReturn(org.apache.logging.log4j.Level.ERROR);
  when(event.getThrownProxy()).thenReturn(new ThrowableProxy(EXCEPTION));
  when(event.getContextData()).thenReturn(contextData);
  when(event.getContextStack()).thenReturn(null);
  when(event.getMessage()).thenReturn(message);

  sut.append(event);

  Map<String, Object> expectedCustom = buildExpectedCustom(LOGGER_NAME,
      new HashMap<String, Object>(MDC), null, MARKER_NAME, THREAD_NAME);

  verify(rollbar).log(throwableWrapper, expectedCustom, FORMATTED_MESSAGE, Level.ERROR, false);
}
 
Example #7
Source File: RollbarAppenderTest.java    From rollbar-java with MIT License 6 votes vote down vote up
@Test
public void shouldLogEventWhenNoMDC() {
  RollbarThrowableWrapper throwableWrapper = new RollbarThrowableWrapper(EXCEPTION);

  when(event.getLoggerName()).thenReturn(LOGGER_NAME);
  when(event.getMarker()).thenReturn(marker);
  when(event.getThreadName()).thenReturn(THREAD_NAME);
  when(event.getLevel()).thenReturn(org.apache.logging.log4j.Level.ERROR);
  when(event.getThrownProxy()).thenReturn(new ThrowableProxy(EXCEPTION));
  when(event.getContextData()).thenReturn(null);
  when(event.getContextStack()).thenReturn(contextStack);
  when(event.getMessage()).thenReturn(message);

  sut.append(event);

  Map<String, Object> expectedCustom = buildExpectedCustom(LOGGER_NAME,
      null, NDC, MARKER_NAME, THREAD_NAME);

  verify(rollbar).log(throwableWrapper, expectedCustom, FORMATTED_MESSAGE, Level.ERROR, false);
}
 
Example #8
Source File: RollbarAppenderTest.java    From rollbar-java with MIT License 6 votes vote down vote up
@Test
public void shouldLogEventWhenNoMarker() {
  RollbarThrowableWrapper throwableWrapper = new RollbarThrowableWrapper(EXCEPTION);

  when(event.getLoggerName()).thenReturn(LOGGER_NAME);
  when(event.getThreadName()).thenReturn(THREAD_NAME);
  when(event.getLevel()).thenReturn(org.apache.logging.log4j.Level.ERROR);
  when(event.getThrownProxy()).thenReturn(new ThrowableProxy(EXCEPTION));
  when(event.getContextData()).thenReturn(contextData);
  when(event.getContextStack()).thenReturn(contextStack);
  when(event.getMessage()).thenReturn(message);

  sut.append(event);

  Map<String, Object> expectedCustom = buildExpectedCustom(LOGGER_NAME,
      new HashMap<String, Object>(MDC), NDC, null, THREAD_NAME);

  verify(rollbar).log(throwableWrapper, expectedCustom, FORMATTED_MESSAGE, Level.ERROR, false);
}
 
Example #9
Source File: RollbarAppenderTest.java    From rollbar-java with MIT License 6 votes vote down vote up
@Test
public void shouldLogEventWithAllInformationFromThrowableProxyWithThrowable() {
  ThrowableWrapper throwableWrapper = new RollbarThrowableWrapper(EXCEPTION);

  when(event.getLoggerName()).thenReturn(LOGGER_NAME);
  when(event.getMarker()).thenReturn(marker);
  when(event.getThreadName()).thenReturn(THREAD_NAME);
  when(event.getLevel()).thenReturn(org.apache.logging.log4j.Level.ERROR);
  when(event.getThrownProxy()).thenReturn(new ThrowableProxy(EXCEPTION));
  when(event.getContextData()).thenReturn(contextData);
  when(event.getContextStack()).thenReturn(contextStack);
  when(event.getMessage()).thenReturn(message);

  sut.append(event);

  Map<String, Object> expectedCustom = buildExpectedCustom(LOGGER_NAME,
      new HashMap<String, Object>(MDC), NDC, MARKER_NAME, THREAD_NAME);

  verify(rollbar).log(throwableWrapper, expectedCustom, FORMATTED_MESSAGE, Level.ERROR, false);
}
 
Example #10
Source File: RollbarAppender.java    From rollbar-java with MIT License 6 votes vote down vote up
private ThrowableWrapper buildRollbarThrowableWrapper(ThrowableProxy throwableProxy) {
  if (throwableProxy == null) {
    return null;
  }

  if (throwableProxy.getThrowable() != null) {
    return new RollbarThrowableWrapper(throwableProxy.getThrowable());
  }

  String className = throwableProxy.getName();
  String message = throwableProxy.getMessage();
  ThrowableWrapper causeThrowableWrapper =
      buildRollbarThrowableWrapper(throwableProxy.getCauseProxy());
  StackTraceElement[] stackTraceElements = buildStackTraceElements(
      throwableProxy.getStackTrace());

  return new RollbarThrowableWrapper(className, message, stackTraceElements,
      causeThrowableWrapper);
}
 
Example #11
Source File: RollbarAppender.java    From rollbar-java with MIT License 6 votes vote down vote up
@Override
public void append(LogEvent event) {
  if (event.getLoggerName() != null && event.getLoggerName().startsWith(PACKAGE_NAME)) {
    LOGGER.warn("Recursive logging from [{}] for appender [{}].", event.getLoggerName(),
        getName());
    return;
  }

  ThrowableProxy throwableProxy = event.getThrownProxy();
  ThrowableWrapper rollbarThrowableWrapper = buildRollbarThrowableWrapper(throwableProxy);
  Map<String, Object> custom = this.buildCustom(event);
  String message = event.getMessage() != null ? event.getMessage().getFormattedMessage() : null;
  Level level = this.getLevel(event);

  rollbar.log(rollbarThrowableWrapper, custom, message, level, false);
}
 
Example #12
Source File: ExtendedThrowablePatternConverterTest.java    From logging-log4j2 with Apache License 2.0 6 votes vote down vote up
@Test
public void testDeserializedLogEventWithThrowableProxyButNoThrowable() {
	final ExtendedThrowablePatternConverter converter = ExtendedThrowablePatternConverter.newInstance(null, null);
	final Throwable originalThrowable = new Exception("something bad happened");
	final ThrowableProxy throwableProxy = new ThrowableProxy(originalThrowable);
	final Throwable deserializedThrowable = null;
       final Log4jLogEvent event = Log4jLogEvent.newBuilder() //
               .setLoggerName("testLogger") //
               .setLoggerFqcn(this.getClass().getName()) //
               .setLevel(Level.DEBUG) //
               .setMessage(new SimpleMessage("")) //
               .setThrown(deserializedThrowable) //
               .setThrownProxy(throwableProxy) //
               .setTimeMillis(0).build();
	final StringBuilder sb = new StringBuilder();
	converter.format(event, sb);
	final String result = sb.toString();
	assertTrue(result, result.contains(originalThrowable.getMessage()));
	assertTrue(result, result.contains(originalThrowable.getStackTrace()[0].getMethodName()));
}
 
Example #13
Source File: ExtendedLog4j2JsonModule.java    From log4j2-elasticsearch with Apache License 2.0 6 votes vote down vote up
@Override
public void setupModule(SetupContext context) {
    super.setupModule(context);

    context.setMixInAnnotations(StackTraceElement.class, StackTraceElementMixIn.class);
    context.setMixInAnnotations(Marker.class, MarkerMixIn.class);
    context.setMixInAnnotations(Level.class, LevelMixIn.class);
    context.setMixInAnnotations(ExtendedStackTraceElement.class, ExtendedStackTraceElementMixIn.class);
    context.setMixInAnnotations(ThrowableProxy.class, ThrowableProxyMixIn.class);

    context.setMixInAnnotations(Message.class, MessageJacksonJsonMixIn.class);

    // https://github.com/rfoltyns/log4j2-elasticsearch/issues/9, timeMillis can't be ignored
    context.setMixInAnnotations(LogEvent.class, LogEventJacksonJsonMixIn.class);

}
 
Example #14
Source File: RollbarAppenderTest.java    From rollbar-java with MIT License 5 votes vote down vote up
@Test
public void shouldLogEventWithAllInformationFromThrowableProxyWithoutThrowable() {
  ThrowableProxy throwableProxy = mock(ThrowableProxy.class);
  when(throwableProxy.getThrowable()).thenReturn(null);
  when(throwableProxy.getName()).thenReturn(EXCEPTION.getClass().getName());
  when(throwableProxy.getMessage()).thenReturn(EXCEPTION.getMessage());
  when(throwableProxy.getCauseProxy()).thenReturn(new ThrowableProxy(NESTED_EXCEPTION));
  when(throwableProxy.getStackTrace()).thenReturn(EXCEPTION.getStackTrace());

  ThrowableWrapper throwableWrapper = new RollbarThrowableWrapper(EXCEPTION.getClass().getName(),
      EXCEPTION.getMessage(), EXCEPTION.getStackTrace(),
      new RollbarThrowableWrapper(NESTED_EXCEPTION));

  when(event.getLoggerName()).thenReturn(LOGGER_NAME);
  when(event.getMarker()).thenReturn(marker);
  when(event.getThreadName()).thenReturn(THREAD_NAME);
  when(event.getLevel()).thenReturn(org.apache.logging.log4j.Level.ERROR);
  when(event.getThrownProxy()).thenReturn(throwableProxy);
  when(event.getContextData()).thenReturn(contextData);
  when(event.getContextStack()).thenReturn(contextStack);
  when(event.getMessage()).thenReturn(message);

  sut.append(event);

  Map<String, Object> expectedCustom = buildExpectedCustom(LOGGER_NAME,
      new HashMap<String, Object>(MDC), NDC, MARKER_NAME, THREAD_NAME);

  verify(rollbar).log(throwableWrapper, expectedCustom, FORMATTED_MESSAGE, Level.ERROR, false);
}
 
Example #15
Source File: StackdriverJsonLayout.java    From curiostack with MIT License 5 votes vote down vote up
@JsonGetter
public String getMessage() {
  ThrowableProxy throwProxy = event.getThrownProxy();
  if (throwProxy == null) {
    return event.getMessage().getFormattedMessage();
  } else {
    return event.getMessage().getFormattedMessage()
        + "\n"
        + throwProxy.getExtendedStackTraceAsString();
  }
}
 
Example #16
Source File: RootThrowablePatternConverter.java    From logging-log4j2 with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void format(final LogEvent event, final StringBuilder toAppendTo) {
    final ThrowableProxy proxy = event.getThrownProxy();
    final Throwable throwable = event.getThrown();
    if (throwable != null && options.anyLines()) {
        if (proxy == null) {
            super.format(event, toAppendTo);
            return;
        }
        final String trace = proxy.getCauseStackTraceAsString(options.getIgnorePackages(), options.getTextRenderer(), getSuffix(event), options.getSeparator());
        final int len = toAppendTo.length();
        if (len > 0 && !Character.isWhitespace(toAppendTo.charAt(len - 1))) {
            toAppendTo.append(' ');
        }
        if (!options.allLines() || !Strings.LINE_SEPARATOR.equals(options.getSeparator())) {
            final StringBuilder sb = new StringBuilder();
            final String[] array = trace.split(Strings.LINE_SEPARATOR);
            final int limit = options.minLines(array.length) - 1;
            for (int i = 0; i <= limit; ++i) {
                sb.append(array[i]);
                if (i < limit) {
                    sb.append(options.getSeparator());
                }
            }
            toAppendTo.append(sb.toString());

        } else {
            toAppendTo.append(trace);
        }
    }
}
 
Example #17
Source File: RingBufferLogEventTest.java    From logging-log4j2 with Apache License 2.0 5 votes vote down vote up
@Test
public void testSerializationDeserialization() throws IOException, ClassNotFoundException {
    final RingBufferLogEvent evt = new RingBufferLogEvent();
    final String loggerName = "logger.name";
    final Marker marker = null;
    final String fqcn = "f.q.c.n";
    final Level level = Level.TRACE;
    final Message data = new SimpleMessage("message");
    final Throwable t = new InternalError("not a real error");
    final ContextStack contextStack = null;
    final String threadName = "main";
    final StackTraceElement location = null;
    evt.setValues(null, loggerName, marker, fqcn, level, data, t, (StringMap) evt.getContextData(),
            contextStack, -1, threadName, -1, location,
            new FixedPreciseClock(12345, 678), new DummyNanoClock(1));
    ((StringMap) evt.getContextData()).putValue("key", "value");

    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    final ObjectOutputStream out = new ObjectOutputStream(baos);
    out.writeObject(evt);

    final ObjectInputStream in = new FilteredObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
    final RingBufferLogEvent other = (RingBufferLogEvent) in.readObject();
    assertEquals(loggerName, other.getLoggerName());
    assertEquals(marker, other.getMarker());
    assertEquals(fqcn, other.getLoggerFqcn());
    assertEquals(level, other.getLevel());
    assertEquals(data, other.getMessage());
    assertNull("null after serialization", other.getThrown());
    assertEquals(new ThrowableProxy(t), other.getThrownProxy());
    assertEquals(evt.getContextData(), other.getContextData());
    assertEquals(contextStack, other.getContextStack());
    assertEquals(threadName, other.getThreadName());
    assertEquals(location, other.getSource());
    assertEquals(12345, other.getTimeMillis());
    assertEquals(678, other.getInstant().getNanoOfMillisecond());
}
 
Example #18
Source File: ThrowableProxyWithoutStacktraceXmlMixIn.java    From logging-log4j2 with Apache License 2.0 4 votes vote down vote up
@Override
@JacksonXmlElementWrapper(namespace = XmlConstants.XML_NAMESPACE, localName = XmlConstants.ELT_SUPPRESSED)
@JacksonXmlProperty(namespace = XmlConstants.XML_NAMESPACE, localName = XmlConstants.ELT_SUPPRESSED_ITEM)
public abstract ThrowableProxy[] getSuppressedProxies();
 
Example #19
Source File: ThrowableProxyWithStacktraceAsStringXmlMixIn.java    From logging-log4j2 with Apache License 2.0 4 votes vote down vote up
@Override
@JacksonXmlElementWrapper(namespace = XmlConstants.XML_NAMESPACE, localName = XmlConstants.ELT_SUPPRESSED)
@JacksonXmlProperty(namespace = XmlConstants.XML_NAMESPACE, localName = XmlConstants.ELT_SUPPRESSED_ITEM)
public abstract ThrowableProxy[] getSuppressedProxies();
 
Example #20
Source File: AbstractLogEvent.java    From logging-log4j2 with Apache License 2.0 4 votes vote down vote up
@Override
public ThrowableProxy getThrownProxy() {
    return null;
}
 
Example #21
Source File: LogEventFixtures.java    From logging-log4j2 with Apache License 2.0 4 votes vote down vote up
/**
 * @return a log event that uses all the bells and whistles, features, nooks and crannies
 */
public static Log4jLogEvent createLogEvent() {
    final Marker cMarker = MarkerManager.getMarker("Marker1");
    final Marker pMarker1 = MarkerManager.getMarker("ParentMarker1");
    final Marker pMarker2 = MarkerManager.getMarker("ParentMarker2");
    final Marker gfMarker = MarkerManager.getMarker("GrandFatherMarker");
    final Marker gmMarker = MarkerManager.getMarker("GrandMotherMarker");
    cMarker.addParents(pMarker1);
    cMarker.addParents(pMarker2);
    pMarker1.addParents(gmMarker);
    pMarker1.addParents(gfMarker);
    final Exception sourceHelper = new Exception();
    sourceHelper.fillInStackTrace();
    final Exception cause = new NullPointerException("testNPEx");
    sourceHelper.fillInStackTrace();
    final StackTraceElement source = sourceHelper.getStackTrace()[0];
    final IOException ioException = new IOException("testIOEx", cause);
    ioException.addSuppressed(new IndexOutOfBoundsException("I am suppressed exception 1"));
    ioException.addSuppressed(new IndexOutOfBoundsException("I am suppressed exception 2"));
    final ThrowableProxy throwableProxy = new ThrowableProxy(ioException);
    final StringMap contextData = ContextDataFactory.createContextData();
    contextData.putValue("MDC.A", "A_Value");
    contextData.putValue("MDC.B", "B_Value");
    final DefaultThreadContextStack contextStack = new DefaultThreadContextStack(true);
    contextStack.clear();
    contextStack.push("stack_msg1");
    contextStack.add("stack_msg2");
    final Log4jLogEvent expected = Log4jLogEvent.newBuilder() //
            .setLoggerName("a.B") //
            .setMarker(cMarker) //
            .setLoggerFqcn("f.q.c.n") //
            .setLevel(Level.DEBUG) //
            .setMessage(new SimpleMessage("Msg")) //
            .setThrown(ioException) //
            .setThrownProxy(throwableProxy) //
            .setContextData(contextData) //
            .setContextStack(contextStack) //
            .setThreadName("MyThreadName") //
            .setSource(source) //
            .setTimeMillis(1).build();
    // validate event?
    return expected;
}
 
Example #22
Source File: ThrowableProxyXmlMixIn.java    From logging-log4j2 with Apache License 2.0 4 votes vote down vote up
@Override
@JacksonXmlElementWrapper(namespace = XmlConstants.XML_NAMESPACE, localName = XmlConstants.ELT_SUPPRESSED)
@JacksonXmlProperty(namespace = XmlConstants.XML_NAMESPACE, localName = XmlConstants.ELT_SUPPRESSED_ITEM)
public abstract ThrowableProxy[] getSuppressedProxies();
 
Example #23
Source File: AbstractLogEventXmlMixIn.java    From logging-log4j2 with Apache License 2.0 4 votes vote down vote up
@JacksonXmlProperty(namespace = XmlConstants.XML_NAMESPACE, localName = XmlConstants.ELT_THROWN)
@Override
public abstract ThrowableProxy getThrownProxy();
 
Example #24
Source File: ThrowableProxyWithStacktraceAsStringMixIn.java    From logging-log4j2 with Apache License 2.0 4 votes vote down vote up
@JsonProperty(JsonConstants.ELT_SUPPRESSED)
public abstract ThrowableProxy[] getSuppressedProxies();
 
Example #25
Source File: TestBaseEntity.java    From logging-log4j2 with Apache License 2.0 4 votes vote down vote up
@Override
@Transient
public ThrowableProxy getThrownProxy() {
    return this.getWrappedEvent().getThrownProxy();
}
 
Example #26
Source File: LogEventEntityTest.java    From logging-log4j2 with Apache License 2.0 4 votes vote down vote up
@Test
public void testToImmutable_AbstractLogEventWrapperEntity() {
    final LogEvent logEvent = new AbstractLogEventWrapperEntity() {

        private static final long serialVersionUID = 2L;

        @Override
        public ContextStack getContextStack() {
            return null;
        }

        @Override
        public Level getLevel() {
            return null;
        }

        @Override
        public String getLoggerFqcn() {
            return null;
        }

        @Override
        public String getLoggerName() {
            return null;
        }

        @Override
        public Marker getMarker() {
            return null;
        }

        @Override
        public Message getMessage() {
            return null;
        }

        @Override
        public Instant getInstant() {
            return new MutableInstant();
        }

        @Override
        public long getNanoTime() {
            return 0;
        }

        @Override
        public StackTraceElement getSource() {
            return null;
        }

        @Override
        public long getThreadId() {
            return 0;
        }

        @Override
        public String getThreadName() {
            return null;
        }

        @Override
        public int getThreadPriority() {
            return 0;
        }

        @Override
        public Throwable getThrown() {
            return null;
        }

        @Override
        public ThrowableProxy getThrownProxy() {
            return null;
        }

        @Override
        public long getTimeMillis() {
            return 0;
        }
    };
    Assert.assertNotSame(logEvent, logEvent.toImmutable());
}
 
Example #27
Source File: LogEventJsonMixIn.java    From logging-log4j2 with Apache License 2.0 4 votes vote down vote up
@JsonProperty(JsonConstants.ELT_THROWN)
@Override
public abstract ThrowableProxy getThrownProxy();
 
Example #28
Source File: ThrowableProxyMixIn.java    From logging-log4j2 with Apache License 2.0 4 votes vote down vote up
@JsonProperty(JsonConstants.ELT_SUPPRESSED)
public abstract ThrowableProxy[] getSuppressedProxies();
 
Example #29
Source File: LogEventWithContextListMixIn.java    From logging-log4j2 with Apache License 2.0 4 votes vote down vote up
@JsonProperty(JsonConstants.ELT_THROWN)
@Override
public abstract ThrowableProxy getThrownProxy();
 
Example #30
Source File: AbstractJacksonLayout.java    From logging-log4j2 with Apache License 2.0 4 votes vote down vote up
@Override
public ThrowableProxy getThrownProxy() {
    return event.getThrownProxy();
}