1 Reply Latest reply on Sep 4, 2015 12:05 PM by jamezp

    JBOSS eap 6.4 logging pattern

    doc_fire

      Trying to achive the following logging pattern:

       

      %d;%p;?localLogEntry1;?localLogEntry2;[%c];(%t);%X{globalLogEntry};%s;%E;%n"/>

       

      where ?localLogEntry1 needs to be defined.

       

      ?localLogEntry1 is an optional entry (e.g. a category of the log or a status) that applies on a single log entry.

       

      MDC is used to implement %X{globalLogEntry} which applies to a big range of logs. The idea was to use MDC also for the ?localLogEntry (i.e. add it to the MDC before the message gets logged and then directly remove it from MDC afterwards) and I do not know if this is a good approach (and it has to be wrapped around all log methods):

         LoggingHelper.putAllToMDC(localLogEntry1, 
      localLogEntry2); logger.warn(message); 
      LoggingHelper.removeFromMDC(localLogEntry1, localLogEntry2);

      At the moment I am using: slf4j, log4j within JBOSS eap 6.4 that is using these conversion characters.

       

      Also im interested in: Does log4j2 change the situation (because it is asynchron and MDC is replaced by Thread Context)?

        • 1. Re: JBOSS eap 6.4 logging pattern
          jamezp

          I'd say MDC is probably your best bet.

           

          FWIW JBoss EAP 6 does not use log4j. Applications that use log4j are supported, but log management is done through the jboss-logmanager you linked which is an extension of JUL.

           

          WRT to log4j2, I have no idea. One would hope MDC works with asynchronous loggers though. There is no support out of the box in JBoss EAP or WildFly for log4j2 though.

           

          --

          James R. Perkins