10 Replies Latest reply on Dec 17, 2012 11:28 AM by jamezp

    JBOSS not logging Debug statements

    deibys

      Hello Guys,

       

      I am running JBOSS 7.1.1 

      In my application I have log4j statements like :

       

       

      public String difundirEvento() {
                logger.info("Iniciando difundirEvento() ... ");
      
      
                String actionReturn = "/difundirEvento/difundir0.xhtml?faces-redirect=true";
      
      
                // Initialize values
                fromEmail = null;
                subject = null;
                broadcastType = null;
                messageType = null;
                testToEmail = null;
                sendingOptions = null;
      
      
                logger.debug("**********************");
                logger.debug("ID Evento = " + eventId);
                logger.debug("**********************");
      
      
                EventosInternoDelegate delegate = new EventosInternoDelegate();
                eventTO = new EventoTO();
                eventTO.setId(eventId);
                eventTO = delegate.buscarEvento(eventTO);
      
                try {
                    urlCorta = UrlShortener.shorten(urlEvento + this.eventTO.getId());
                } catch (Exception ignored) {
                    logger.error("Ocurrió un error al invocar el servicio de url corta ", ignored);
                }
      
                logger.info("Finalizando difundirEvento() ... ");
      
      
                return actionReturn;
          }
      
      

       

      The issue  I am having It is that the debug statemnts are not being printed. I am only getting

      I am ussing the logging framework that comes with JBOSS, so my import statement is import org.jboss.logging.Logger;

       

       

      My configuration in standalone.xml is :

       

      <subsystem xmlns="urn:jboss:domain:logging:1.1">
                  <console-handler name="CONSOLE">
                      <encoding value="UTF-8"/>
                      <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.richfaces" use-parent-handlers="false">
                      <level name="DEBUG"/>
                      <handlers>
                          <handler name="CONSOLE"/>
                      </handlers>
                  </logger>
                  <logger category="org.colfuturo.eventos" use-parent-handlers="false">
                      <level name="DEBUG"/>
                      <handlers>
                          <handler name="CONSOLE"/>
                      </handlers>
                  </logger>
                  <root-logger>
                      <level name="INFO"/>
                      <handlers>
                          <handler name="CONSOLE"/>
                          <handler name="FILE"/>
                      </handlers>
                  </root-logger>
              </subsystem>
      
      

       

       


      How can I make that DEBUG statements are logged ?

      For instance:  This seems not to take any effect:

      <logger category="org.colfuturo.eventos" use-parent-handlers="false">

                      <level name="DEBUG"/>

                      <handlers>

                          <handler name="CONSOLE"/>

                      </handlers>

                  </logger>

        • 1. Re: JBOSS not logging Debug statements
          wdfink

          Do you pack log4j inside your application? Or set some log4j excludes in the jboss-deployment-structure file?

           

          Also I'm not sure whether

            <level name="INFO"/>

          inside the CONSOLE handler is the default, you might test set it to TRACE to see all.

          • 2. Re: JBOSS not logging Debug statements
            lafr

            You have to increase the log-level for the root-logger

            <level name="INFO"/> --> <level name="DEBUG"/>

            or remove the log-level here at all and specify it per handler.


            • 3. Re: JBOSS not logging Debug statements
              deibys

              I am not packing log4j inside the application or set some excludes in jboss-deployment-structure file

              • 4. Re: JBOSS not logging Debug statements
                deibys

                I have set the log level for the root logger to ALL  .  It works, but it starts logging everything  .    Even the server does not start up properly .  

                Why specify  per handler ? Should´t it be the correct way to specify by loggger category ?

                • 5. Re: JBOSS not logging Debug statements
                  wdfink

                  Normally it should work if you add a <logger category=".."> for your application and set the <level name="TRACE"> (instead of INFO) for the CONSOLE handler as this will suppress DEBUG/TRACE messages for console.

                   

                  If you do not change the level for CONSOLE the statements should be logged into the server.log (if you have parent-handler enabled)

                  • 6. Re: JBOSS not logging Debug statements
                    jamezp

                    Yes, your configuration looks correct. What is the category of your logger?

                     

                    --

                    James R. Perkins

                    • 7. Re: JBOSS not logging Debug statements
                      deibys

                      Hello Guys,

                       

                      I have not been able to work out , the logging of my application in JBOSS

                      I have attached to the original question two files:

                       

                      +  standalone.xml  -    configuration file of server

                      LoggingTest.war  -    an war file project.   This is an example of the issue I am having

                       

                      I am using the logging framework embedded in JBOSS application server 7.1

                       

                       

                      In the example project , I have debug statements like :

                       

                      public String login() {

                                logger.info("Iniciando login....");

                       

                                logger.debug("Usuario = " + usuario);

                                logger.debug("Usuario = " + password);

                       

                                logger.info("Finalizando login....");

                       

                                return null;

                          }

                       

                      Those statements are not shown in the console, even if in the logging configuration I have set it ( I guess I have done it )

                       

                      <logger category="org.colfuturo.logging" use-parent-handlers="true">

                                      <level name="ALL"/>

                                      <handlers>

                                          <handler name="CONSOLE"/>

                                      </handlers>

                                  </logger>

                       

                       

                       

                      Thanks,

                      Deibys Quintero

                      • 8. Re: JBOSS not logging Debug statements
                        wdfink

                        As I mentioned before the CONSOLE handler contains a level information to suppress messages with a finer level.

                        The default is INFO so you will not see any message finer than this level.

                        You might check whether remove the <level name="INFO/> help or you need to add <level name="DEBUG"/> to be sure that it is not limited (maybe INFO is the default)

                        • 9. Re: JBOSS not logging Debug statements
                          deibys

                          Hi Wolf,

                           

                          I have set the CONSOLE level to DEBUG and ALL . None of those work   . I have also tried removing it, and no luck

                           

                          Bellow is the configuration in standalone.xml:

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

                                      <console-handler name="CONSOLE">

                                          <level name="DEBUG"/>

                                                                  <encoding value="UTF-8"/>

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

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

                                          <level name="ALL"/>

                                          <formatter>

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

                                          </formatter>

                                          <file relative-to="jboss.server.log.dir" path="colfuturo.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.richfaces" use-parent-handlers="false">

                                          <level name="ALL"/>

                                          <handlers>

                                              <handler name="CONSOLE"/>

                                              <handler name="FILE-COLFUTURO"/>

                                          </handlers>

                                      </logger>

                                      <logger category="org.colfuturo.eventos" use-parent-handlers="false">

                                          <level name="DEBUG"/>

                                      </logger>

                                      <logger category="org.colfuturo.logging" use-parent-handlers="false">

                                          <level name="DEBUG"/>

                                          <handlers>

                                              <handler name="CONSOLE"/>

                                              <handler name="FILE-COLFUTURO"/>

                                          </handlers>

                                      </logger>

                                      <root-logger>

                                          <level name="INFO"/>

                                          <handlers>

                                              <handler name="CONSOLE"/>

                                              <handler name="FILE"/>

                                          </handlers>

                                      </root-logger>

                                  </subsystem>

                           

                           

                           

                          Thanks,Deibys

                          • 10. Re: JBOSS not logging Debug statements
                            jamezp

                            I think I see the issue. I was looking at the source and it looks like the way you're creating your logger is the issue.

                             

                            You're using:

                            private static final Logger logger = Logger.getLogger(LoggingBeanTest.class.toString());
                            

                             

                            You should be using:

                            private static final Logger logger = Logger.getLogger(LoggingBeanTest.class.getName());
                            

                             

                            or simply:

                            private static final Logger logger = Logger.getLogger(LoggingBeanTest.class);
                            

                             

                            The problem is on Class.toString() it prefixes the result with "class", e.g. your category is:

                            class org.colfuturo.logging.LoggingBeanTest
                            

                             

                            Since you define your category as the package in the configuration, which is correct BTW, but your parent logger category is technically "class org" you wouldn't see any debug statements as the root logger is set to INFO.

                             

                            --

                            James R. Perkins