10 Replies Latest reply on Aug 11, 2013 10:49 PM by James Perkins

    DEBUG statements not getting logged to server.log file

    Madhusudhan raju Newbie

      Hi,

       

      I'm running my application in standalone mode.

       

      Application's DEBUG statements which imports " org.apache.log4j" are not getting logged to server.log file, my logging subsystem in standalone.xml looks like below.

       

      Can someone pls help me how can i do configure DEBUG, ERROR and FATAL logging for my application???

       

      <subsystem xmlns="urn:jboss:domain:logging:1.1">

                  <console-handler name="CONSOLE">

                      <level name="INFO"/>

                      <formatter>

                          <pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>

                      </formatter>

                  </console-handler>

                  <periodic-rotating-file-handler name="FILE">

                      <formatter>

                          <pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>

                      </formatter>

                      <file relative-to="jboss.server.log.dir" path="server.log"/>

                      <suffix value=".yyyy-MM-dd"/>

                      <append value="true"/>

                  </periodic-rotating-file-handler>

                  <logger category="com.arjuna">

                      <level name="WARN"/>

                  </logger>

                  <logger category="org.apache.tomcat.util.modeler">

                      <level name="WARN"/>

                  </logger>

                  <logger category="sun.rmi">

                      <level name="WARN"/>

                  </logger>

                  <logger category="jacorb">

                      <level name="WARN"/>

                  </logger>

                  <logger category="jacorb.config">

                      <level name="ERROR"/>

                  </logger>

          <logger category="org.jboss.as.jpa">

                      <level name="DEBUG"/>

                  </logger>

                  <logger category="org.jboss.as.server">

                      <level name="ERROR"/>

                  </logger>

                  <logger category="org.jboss.as.logging">

                      <level name="FATAL"/>

                  </logger>

                  <root-logger>

                      <level name="INFO"/>

                      <handlers>

                          <handler name="CONSOLE"/>

                          <handler name="FILE"/>

                      </handlers>

                  </root-logger>

              </subsystem>

        • 1. Re: DEBUG statements not getting logged to server.log file
          Frank Langelage Master

          Try to set <root-logger><level-name> to DEBUG instead of INFO.

           

          In my file I removed this element completely and added <level name="DEBUG"/> as child to the <periodic-rotating-file-handler name="FILE">, similar to the level definition for console.

          • 2. Re: DEBUG statements not getting logged to server.log file
            Madhusudhan raju Newbie

            No luck, still application DEBUG statements are not logging.

             

             

            If am changing the <rroot-logger> to DEBUG, server startup debug statements are logging.

             

            If i want to add the <level name="DEBUG"/> as child, to which category i have to assign.

             

            Also pls let me know the category for ERROR and FATAL logging level.

             

            Regads,

            Madhu

            • 3. Re: DEBUG statements not getting logged to server.log file
              Frank Langelage Master

              See also https://docs.jboss.org/author/display/AS71/Logging+Configuration

               

              You have to create a logger with a category fitting your application. What's your package name?

               

              And you can use more than one entry, the more specific one "wins". E.g.

                          <logger category="jacorb">

                              <level name="WARN"/>

                          </logger>

                          <logger category="jacorb.config">

                              <level name="ERROR"/>

                          </logger>

              From package jacorb.* we'll see only WARN-messages, jacorb.config.* is further limited to only ERROR.

              • 4. Re: DEBUG statements not getting logged to server.log file
                Wolf-Dieter Fink Master

                Also you should check that you did not pack the log4j.jar with the application.

                Only set a dependency to "org.apache.log4j" module

                • 5. Re: DEBUG statements not getting logged to server.log file
                  Madhusudhan raju Newbie

                  Hi,

                   

                  I've removed log4j.jar from lib folder and i see log4j.jar under JBoss_Home/modules/com/apache/log4j/main, so configured as a module and module.xml looks like below:

                   

                  <module xmlns="urn:jboss:module:1.1" name="org.apache.log4j">
                      <resources>
                          <resource-root path="log4j-1.2.16-redhat-2.jar"/>
                      </resources>
                      <dependencies>
                       <module name="javax.api"/>
                       <module name="javax.transaction.api"/>
                       <module name="org.dom4j" optional="true"/>
                       <module name="org.jboss.logmanager"/>
                       <module name="org.jboss.modules"/>
                      </dependencies>
                  </module>

                   

                  On jboss startup index file got create in the above directory. When accessing application am getting the following error in server.log file and no applciation logs get logged

                   

                  05:20:35,924 ERROR [stderr] (ajp-/127.0.0.1:8009-1) log4j:WARN No appenders could be found for logger (app.com.install.servlet.MainServlet).

                  05:20:35,924 ERROR [stderr] (ajp-/127.0.0.1:8009-1) log4j:WARN Please initialize the log4j system properly.

                  05:20:35,925 ERROR [stderr] (ajp-/127.0.0.1:8009-1) log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

                   

                   

                   

                  Can you pls let me the cause and what changes i have to do.

                   

                  FYI, i have the following packages in my WAR file:

                  app.com.install.servlet

                  app.com.server.servlet

                  app.com.app.servlet

                   

                   

                  • 6. Re: DEBUG statements not getting logged to server.log file
                    Madhusudhan raju Newbie

                    Hi,

                     

                    My issue got resolved to some extent by doing the following:

                     

                    - included log4j.jar file under lib

                    - added following in logging urn section in standalone.xml

                     

                                   <logger category="org.jboss">
                                    <level name="DEBUG"/>
                                   </logger>

                     

                     

                    With this able to log DEBUG statements, now only issue is i get to see FINE, FINER and FINEST logs also which is not required.

                     

                    Any idea how to eliminate this additional logs???

                     

                    • 7. Re: DEBUG statements not getting logged to server.log file
                      Wolf-Dieter Fink Master

                      The level FINE, FINER FINEST are declared in java.util, as the representation is a int you will see FINE, If I remember correct FINER is between DEBUG/TRACE and FINEST==TRACE, so you will see FINE if you set DEBUG level.

                      • 8. Re: DEBUG statements not getting logged to server.log file
                        James Perkins Master

                        It looks like you might have a logging configuration file in your deployment. Try adding -Dorg.jboss.as.logging.per-deployment=false when starting the server and see if that helps.

                         

                        --

                        James R. Perkins

                        • 9. Re: DEBUG statements not getting logged to server.log file
                          Madhusudhan raju Newbie

                          Yes, i do have log4j.xml, log4j.jar in a war classed root and standalone-deplyment-structure.xml to exclude log4j in jboss module

                           

                          I tried adding "-Dorg.jboss.as.logging.per-deployment=false" during the startup in the windows registry as below and landed up with the below exceptions.

                           

                          How can i overcome this errors?

                           

                          Registry:

                           

                          [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\JBAS6SVC\Parameters]
                          "ServiceFile"="service.bat"
                          "WorkingPath"="C\\jboss-6.01\\bin"
                          "JVM Library"="C\\Java\\JDK\\jre\\bin\\server\\jvm.dll"
                          "JVM Option Count"=dword:00000008
                          "JVM Option Number 0"="-Djava.class.path=C:\\jboss-6.01\\jboss-modules.jar;C:\\Java\\JDK\\lib\\tools.jar"
                          "Start Class"="org.jboss.Main"
                          "Start Method"="main"
                          "Start Param Count"=dword:00000008
                          "Start Param Number 0"="-b"
                          "Start Param Number 1"="Server_Name"
                          "Start Param Number 2"="-g"
                          "Start Param Number 3"="Server_Name1_Partition"
                          "Start Param Number 4"="-u"
                          "Start Param Number 5"="230.1.1.1"
                          "Start Param Number 6"="-Dorg.jboss.as.logging.per-deployment=false"

                          Server.log:

                           

                          03:24:37,099 ERROR [stderr] (MSC service thread 1-3) java.lang.ClassNotFoundException: org.jboss.logging.log4j.JDKLevel from [Module "org.jboss.log4j.logmanager:main" from local module loader @544b02 (roots: C\jboss-6.01\modules)]

                          03:24:37,100 ERROR [stderr] (MSC service thread 1-3)  at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)

                          03:24:37,100 ERROR [stderr] (MSC service thread 1-3)  at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
                          03:24:37,100 ERROR [stderr] (MSC service thread 1-3)  at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
                          03:24:37,100 ERROR [stderr] (MSC service thread 1-3)  at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
                          03:24:37,100 ERROR [stderr] (MSC service thread 1-3)  at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
                          03:24:37,101 ERROR [stderr] (MSC service thread 1-3)  at java.lang.Class.forName0(Native Method)
                          03:24:37,101 ERROR [stderr] (MSC service thread 1-3)  at java.lang.Class.forName(Class.java:190)
                          03:24:37,101 ERROR [stderr] (MSC service thread 1-3)  at org.apache.log4j.helpers.Loader.loadClass(Loader.java:198)
                          03:24:37,101 ERROR [stderr] (MSC service thread 1-3)  at org.apache.log4j.xml.DOMConfigurator.parseLevel(DOMConfigurator.java:667)
                          03:24:37,101 ERROR [stderr] (MSC service thread 1-3)  at org.apache.log4j.xml.DOMConfigurator.parseChildrenOfLoggerElement(DOMConfigurator.java:536)

                           

                          • 10. Re: DEBUG statements not getting logged to server.log file
                            James Perkins Master

                            I'm not sure what would cause this error, but it looks really strange. It looks like JBoss Logging isn't finding log4j which is in the org.jboss.log4j.logmanager module. I'm not sure why this would happen though.

                             

                            --

                            James R. Perkins