1 Reply Latest reply on Aug 11, 2014 12:32 AM by Ebbe George Haabendal Brandstrup

    Logging: NDC info is lost in logs when passed through an async handler

    Ebbe George Haabendal Brandstrup Newbie



      I am running Wildfly 8.1.0 final in standalone mode and I'm seeing an issue with NDC (nested diagnostics context) not getting propagated for logs that pass through an async handler.


      In particular, I'm seeing this on the size-rotating-file-handler. I set a string on NDC in my Java code and it comes out as expected if I assign the log handler directly to my root logger. However, if I put an async handler in between, all logs still come out - but with an empty value for the NDC.


      I've included my log handler setup from standalone.xml below:


      <!-- Formatter that includes NDC (%x) -->
      <formatter name="logid-formatter">
           <pattern-formatter pattern="%d %-5p [%c] (%t) [file: %F:%L, logid: %x] - %s%E%n" />
      <!-- Log handler - prints out NDC data when added directly to the root logger, but prints out an empty value for NDC when added to the async handler -->
      <size-rotating-file-handler name="xyzServer">
                <named-formatter name="logid-formatter"/>
           <file relative-to="jboss.server.log.dir" path="xyz-server.log"/>
           <rotate-size value="100m"/>
           <max-backup-index value="10"/>
      <!-- Async handler, with the size-rotating-file-handler added as sub-handler -->
      <async-handler name="ASYNC_xyzServer">
           <queue-length value="128"/>
           <overflow-action value="block"/>
                <handler name="xyzServer"/>
           <level name="INFO"/>
                <handler name="ASYNC_xyzServer"/>

      Any help as to why this might be occurring would be greatly appreciated, thanks!


      Best regards,

      Ebbe Brandstrup