2 Replies Latest reply on Jun 20, 2011 5:45 AM by legae

    jboss 6.1 logging problem

    legae Newbie

      I have made no changes to jboss-logging.xml. I just added log4j.xml file to conf directory and everything was logged properly.

      I had to made changes in  file 'ear-deployer-jboss-beans.xml'. I changed in 'EARClassLoaderDeployer'  <property name="isolated">false</property> (from true to false because we have two .ear applications which need acces to the same data - I don't want to change this part of code). NOw the application works but... in server.log file there is nothing logged.

      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
      
      <!-- ===================================================================== -->
      <!--                                                                       -->
      <!--  Log4j Configuration                                                  -->
      <!--                                                                       -->
      <!-- ===================================================================== -->
      
      <!-- $Id: jboss-log4j.xml 65459 2007-09-19 00:25:51Z dimitris@jboss.org $ -->
      
      <!--
         | For more configuration infromation and examples see the Jakarta Log4j
         | owebsite: http://jakarta.apache.org/log4j
       -->
      
      <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
      
         <!-- ================================= -->
         <!-- Preserve messages in a local file -->
         <!-- ================================= -->
      
         <!-- A size based file rolling appender-->
         <appender name="FILE" class="org.apache.log4j.RollingFileAppender">
           <errorHandler class="org.apache.log4j.helpers.OnlyOnceErrorHandler"/>
           <param name="File" value="${jboss.server.home.dir}/log/server.log"/>
           <param name="Append" value="true"/>
           <param name="MaxFileSize" value="500MB"/>
           <param name="MaxBackupIndex" value="2"/>
           <param name="Threshold" value="TRACE"/>
           <layout class="org.apache.log4j.PatternLayout">
             <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
           </layout>
         </appender>
      
      <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
            <errorHandler class="org.apache.log4j.helpers.OnlyOnceErrorHandler"/>
            <param name="Target" value="System.out"/>
            <param name="Threshold" value="ERROR"/>
      
            <layout class="org.apache.log4j.PatternLayout">
               <!-- The default pattern: Date Priority [Category] Message\n -->
               <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
            </layout>
         </appender>
      
      <category name="org.apache">
            <priority value="ERROR"/>
         </category>
      
         <category name="jacorb">
            <priority value="ERROR"/>
         </category>
         
         <category name="org.jgroups">
            <priority value="ERROR"/>
         </category>
         
         <category name="org.quartz">
            <priority value="ERROR"/>
         </category>
         
         <category name="javax">
            <priority value="WARN"/>
         </category>   
      
         <category name="org.jboss.management">
            <priority value="ERROR"/>
         </category>
         
         <category name="org.jboss.serial">
            <priority value="ERROR"/>
         </category>
      
         <category name="org.jboss">
            <priority value="ERROR"/>
         </category>
      
         <category name="org.hibernate">
            <priority value="ERROR"/>
         </category>
         
         <category name="com.myApp">
            <priority value="TRACE"/>
         </category>
      
       <root>
            <appender-ref ref="CONSOLE"/>
            <appender-ref ref="FILE"/>
         </root>
      
      </log4j:configuration>
      

       

       

      I debugged this and when I use code

      org.apache.log4j.Logger logger =  org.apache.log4j.Logger.getLogger(MyClass.class);
      

       

      the returned class is org.jboss.logmanager.log4j.BridgeLogger.

       

      My .ear application has structure

      app.ear

            \app.jar

            \lib

                \log4j-1.2.15.jar

       

      Why proprerty 'isolated' has impact on logging?  and what do I have to do to have logs? ('isolated' property need to stay 'false')

        • 1. Re: jboss 6.1 logging problem
          legae Newbie

          I have following code: 

           

          org.apache.log4j.Logger logger =  org.apache.log4j.Logger.getLogger(MyClass.class);

           

          logger.warn("class: " + logger

                              + " efffLevel "

                              + logger.getEffectiveLevel()

                              + " name "

                              + logger.getName()

                              + " root "

                              + logger.getRootLogger()

                              + " rootLoggerName "

                              + logger.getRootLogger().getName());

           

                      Enumeration<AppenderSkeleton> skels = logger.getRootLogger().getAllAppenders();

                      while (skels.hasMoreElements()) {

                          AppenderSkeleton skel = skels.nextElement();

                          logger.warn("errHandler: " + skel.getErrorHandler()

                                  + "name: "

                                  + skel.getName()

                                  + " threshold: "

                                  + skel.getThreshold());

                      }

           

           

           

          When the <property name="isolated">true</property> is set the log files look like this

           

          boot.log contains:

          13:43:37,903 INFO  [STDOUT] log4j: Trying to find [log4j.xml] using context classloader BaseClassLoader@c22b28{vfs:///D:/appserver/jboss-6.1.0-SNAPSHOT/server/default/deploy/SimpleTests.ear}.
          13:43:37,909 INFO  [STDOUT] log4j: Using URL [vfs:/D:/appserver/jboss-6.1.0-SNAPSHOT/server/default/conf/log4j.xml] for automatic log4j configuration.
          13:43:37,915 INFO  [STDOUT] log4j: Preferred configurator class: org.apache.log4j.xml.DOMConfigurator
          13:43:37,927 INFO  [STDOUT] log4j: System property is :null
          13:43:37,930 INFO  [STDOUT] log4j: Standard DocumentBuilderFactory search succeded.
          13:43:37,932 INFO  [STDOUT] log4j: DocumentBuilderFactory is: org.apache.xerces.jaxp.DocumentBuilderFactoryImpl
          13:43:37,948 INFO  [STDOUT] log4j: debug attribute= "false".
          

           

          and the server.log contains:

           

          2011-06-14 13:43:38,021 WARN  [com.myApp.service.MyClass] class: org.apache.log4j.Logger@b25884 efffLevel TRACE name com.myApp.service.MyClass root org.apache.log4j.spi.RootLogger@d16451 rootLoggerName root
          2011-06-14 13:43:38,021 WARN  [com.myApp.service.MyClass] errHandler: org.apache.log4j.helpers.OnlyOnceErrorHandler@1112836name: CONSOLE threshold: ERROR
          2011-06-14 13:43:38,022 WARN  [com.myApp.service.MyClass] errHandler: org.apache.log4j.helpers.OnlyOnceErrorHandler@1672f52name: FILE threshold: TRACE
          
          

           

          the level is propert is set to TRACE and appenders are visible

           

          but when the <property name="isolated">false</property> logs look totally different

           

          boot.log:

          14:18:35,474 WARN  [MyClass] class: org.jboss.logmanager.log4j.BridgeLogger@319202 efffLevel DEBUG name com.myApp.service.MyClass root org.jboss.logmanager.log4j.BridgeLogger@5c9cd8 rootLoggerName 
          

           

          No appenders!! and nothing about trying to find log4j.xml file - why? is there any other file used? and effective level is DEBUG

           

          server.log:

          2011-06-14 14:18:36,362 TRACE [org.jnp.server.NamingServer] (Thread-2) bind AppName=org.jnp.interfaces.MarshalledValuePair@1ae42b1, java.lang.String
          2011-06-14 14:18:36,363 TRACE [org.jnp.server.NamingServer] (Thread-2) org.jnp.server.NamingServer@19c8dff, No binding for: AppName in context , bindings:
          
          2011-06-14 14:18:36,364 TRACE [org.jnp.server.NamingServer] (Thread-2) org.jnp.server.NamingServer@19c8dff, setBinding: name=AppName, obj=org.jnp.interfaces.MarshalledValuePair@1ae42b1, className=java.lang.String
          2011-06-14 14:18:36,364 TRACE [org.jnp.server.NamingServer] (Thread-2) Skipping event dispatch because there is no EventMgr
          2011-06-14 14:18:36,435 INFO  [org.apache.coyote.http11.Http11Protocol] (Thread-2) Starting Coyote HTTP/1.1 on http-127.0.0.1-8080
          2011-06-14 14:18:36,449 INFO  [org.apache.coyote.ajp.AjpProtocol] (Thread-2) Starting Coyote AJP/1.3 on ajp-127.0.0.1-8009
          2011-06-14 14:18:36,457 INFO  [org.apache.coyote.http11.Http11Protocol] (Thread-2) Starting Coyote HTTP/1.1 on http-127.0.0.1-8443
          2011-06-14 14:18:36,461 INFO  [org.jboss.bootstrap.impl.base.server.AbstractServer] (Thread-2) JBossAS [6.1.0.SNAPSHOT "Neo"] Started in 37s:629ms
          

           

          no logs related to my application.

           

          Where is the problem? I see that log4j.xml file is not used. Is there some special configuration file used and where I can find it? Or maybe the ear need to be build differently. I tried to add log4j.xml inside ear but it didn't help. Does anyone have similar problems?

          • 2. Re: jboss 6.1 logging problem
            legae Newbie

            I found solution to my problem.

            I changed back isolated property to true <property name="isolated">true</property>  and added to each .ear  jboss-app.xml

            app.ear

                 \META-INF

                       \jboss-app.xml   

                  \app.jar

                  \lib

                      \log4j-1.2.15.jar

             

            app2.ear

                 \META-INF

                       \jboss-app.xml   

                  \app2.jar

                  \lib

                      \log4j-1.2.15.jar

             

            both jboss-app.xml contain:

             

            <?xml version="1.0" encoding="UTF-8"?>

            <jboss-app>

              <loader-repository>

              companyName:loader=apps  

                 <loader-repository-config>

                 java2ParentDelegation=false

                 </loader-repository-config>

              </loader-repository>

            </jboss-app>

             

            Now I see in jmx console -> jboss.classloader-> domain=companyName:loader=apps,system=11446032 and logging works perfectly (any changes in jboss-logging.xml is propagated properly) and my .ears use the same classloader.

            I based on http://community.jboss.org/wiki/ClassLoadingConfiguration part: "isolation with overriding server classes"