0 Replies Latest reply on Aug 26, 2015 3:17 AM by marco -

    JBOSS eap 6.4 logging pattern

    marco - Newbie

      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)?