logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark Celano (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (LOG4J2-886) Not serializing the exception or ThreadContext (MDC)
Date Mon, 27 Oct 2014 13:46:33 GMT

    [ https://issues.apache.org/jira/browse/LOG4J2-886?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14185131#comment-14185131
] 

Mark Celano commented on LOG4J2-886:
------------------------------------

  Please add the following test case to the org.apache.logging.log4j.core.appender.SocketAppenderTest

  @Test
    public void testPropertyAppender() throws Exception {
        org.apache.logging.log4j.Logger LOG2 = org.apache.logging.log4j.LogManager.getLogger(SocketAppenderTest.class.getName());

        // NDC Stack - Nested Diagnostic Context
        org.apache.logging.log4j.ThreadContext.push("NDC: " + "Message");

        // MDC Stack - Mapped Diagnostic Context
        org.apache.logging.log4j.ThreadContext.getContext().put("MDC", "value");

        LOG2.fatal("fatal message", new Exception("fatal occurred"));
        LogEvent event = list.poll(3, TimeUnit.SECONDS);

        assertNotNull(event.getContextStack());
        assertEquals("NDC: Message", event.getContextStack().pop());
        assertNotNull(event.getThrown());
        assertEquals("fatal occured", event.getThrown().getMessage());
        assertNotNull(event.getContextMap());
        assertEquals("value", event.getContextMap().get("MDC"));
    }

log4j2.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="DEBUG">

  <Appenders>
    <Console name="STDOUT" target="SYSTEM_OUT">
        <PatternLayout pattern="%d %p %l %m%n"/>
    </Console>
    <Socket name="LF5_SOCKET" host="localhost" port="8199" protocol="TCP" reconnectionDelay="5000">
        <SerializedLayout/>
    </Socket>
  </Appenders>

  <Loggers>
    <Root level="trace">
      <AppenderRef ref="STDOUT" level="DEBUG"/>
      <AppenderRef ref="LF5_SOCKET" level="DEBUG"/>
    </Root>
  </Loggers>

</Configuration>

>  Not serializing the exception or ThreadContext (MDC) 
> ------------------------------------------------------
>
>                 Key: LOG4J2-886
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-886
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Appenders, Layouts
>    Affects Versions: 2.1
>            Reporter: Mark Celano
>
> Not serializing the exception or ThreadContext (MDC) into the serialized LogEvent object
when using the SerializedLayout for the Socket appender.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Mime
View raw message