3 Replies Latest reply on Dec 1, 2011 8:42 AM by pi4630

    Application-specific logging in JBoss AS 6 (yet again)

    pgmjsd

      JBoss AS 6.0.0.Final and app-specific logging -  I've tried putting jboss-logging.xml in the META-INF directory of an EAR deployment as this post suggests.   When JBoss starts it does seem to be reading the file, but the file is always empty.  When I use a JBoss Logging 'Logger', the output shows up in 'server.log', configured in deploy/jboss-logging.xml but never in the application specific log file.   I've tried using the JBoss Logging API directly, but it's as if the application-specific logging configuration is pretty much ignored except initially creating the log file.

       

      Do I have to do something with the class loaders or something?

       

      Here's the jboss-logging file:

       

      <?xml version="1.0" encoding="UTF-8"?>
       <!-- My application jboss-logging.xml -->
       <logging xmlns="urn:jboss:logging:6.0" context="MyApplication">
      
          <!--
            ~ This element, in conjunction with the "context" attribute above, tells the
            ~ logging system that I want my own separate logging environment.
            -->
          <define-context name="MyApplication"/>
      
          <!-- A time/date based rolling handler -->
      
          <periodic-rotating-file-handler
                file-name="${jboss.server.log.dir}/application.log"
                name="FILE"
                autoflush="true"
                append="true"
                suffix=".yyyy-MM-dd">  <!-- To roll over at the top of each hour, use ".yyyy-MM-dd-HH" instead -->
      
             <error-manager>
                <only-once/>
             </error-manager>
      
             <formatter>
                <!-- To revert back to simple stack traces without JAR versions, change "%E" to "%e" below. -->
                <!-- Uncomment this to get the class name in the log as well as the category
                <pattern-formatter pattern="%d %-5p [%c] %C{1} (%t) %s%E%n"/>
                -->
                <!-- Uncomment this to log without the class name in the log -->
                <pattern-formatter pattern="%d %-5p [%c] (%t) %s%E%n"/>
             </formatter>
          </periodic-rotating-file-handler>
      
         <!-- Configure the root logger with my handler from above -->
          <root-logger>
              <level name="DEBUG"/>
              <handlers>
                  <handler-ref name="FILE"/>
              </handlers>
          </root-logger>
      </logging>
      

       

      I can switch over to Log4J, but I want to make sure I'm not missing something obvious before I do that.

        • 1. Re: Application-specific logging in JBoss AS 6 (yet again)
          th.janssen

          I had the same problem. There is nothing written to the log file because the application specific context ist not used. I was able to solve this issue by disabling the on demand mode of the LogContextSelectorService.

          Therefore you have to edit ${jboss.server.dir}/deployers/jboss-logging.deployer/META-INF/logmanager-jboss-beans.xml and remove the mode attribute from the OnDemandJBossLogManagerContextSelector bean element. It is the last bean element at the very end of the file. After deleting the mode attribute, the bean element has to look like this:

           

          {code:xml}

             ...

             <bean name="OnDemandJBossLogManagerContextSelector" class="org.jboss.logmanager.LogContextSelectorService">

                <property name="selector">

                   <inject bean="JBossLogManagerContextSelectorService"/>

                </property>

             </bean>

           

          </deployment>

          {code}

           

          After changing the deployer configuration and restarting the server, the log context is used and the log messages are written to the specified log file.

           

          But I am wondering if the failed on demand context selection is a JBoss bug or if there is something wrong with our application or configuration...

          • 2. Re: Application-specific logging in JBoss AS 6 (yet again)
            srinivasneeluri1

            Hello ,

             

            i am facing the same issue . i did the samething that you suggested still there is not entry in application specific logs .

             

            -Srinivas N

            • 3. Re: Application-specific logging in JBoss AS 6 (yet again)
              pi4630

              See a possibile solution here Application specific logging with JBoss-6.0.0.Final

               

              HTH,

              ~pasquale