2 Replies Latest reply on Nov 15, 2011 11:48 AM by hopkirk

    AS7 and Log4j NDC

    hopkirk

      We are using 7.1.0.Alpha1-SNAPSHOT with Log4j 1.2.16 that comes bundled in /modules.  If I push() a message onto the NDC, it does not come out in the log message.  I have configured the pattern in standalone.xml like so:

       

       

      {code:xml}

                  <console-handler name="CONSOLE" autoflush="true">

                      <level name="TRACE"/>

                      <formatter>

                          <pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c{1}] (%t) (%x) %s%E%n"/>

                      </formatter>

                  </console-handler>

      {code}

       

       

      If I change my class to import jboss logging instead

       

      {code}

      import org.jboss.logging.Logger;

      import org.jboss.logging.NDC;

      {code}

       

       

       

      The log messages now include the NDC.  Am I missing some configuration for using Log4j ?

        • 1. Re: AS7 and Log4j NDC
          hellview

          i'm logging with:

           

          final static org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(MyClass.class);

           

          with this dependency:

           

          <dependency>

              <groupId>org.slf4j</groupId>

              <artifactId>slf4j-api</artifactId>

              <version>1.6.2</version>

              <scope>provided</scope>

          </dependency>

          • 2. Re: AS7 and Log4j NDC
            hopkirk

            Thanks for the reply.

             

            Ideally, we'd like to avoid slf4j.  I think there are issues with the slf4j NDC implementation as well.  Strangely enough, if I keep the log4j Logger but use org.jboss.logging.NDC, the NDC message appears in the logging output.