5 Replies Latest reply on Dec 16, 2008 3:27 AM by Ingo Jobling

    Question on log.debug

    Val Sw Expert
      Hi,

      Not able to get the output of log.debug()

      I am missing some trival configuration.... pls suggest
      log.info() & log.warn() is printing but I am not able to get the output of log.debug()

      I have log4j.xml only under "workspace\project\bootstrap".

      build-dev.properties
      --------------------
      debug=true
      action.dir=WEB-INF/dev

      TestHome.java
      -------------
      @Logger
      Log log;

      System.out.println("CHECK DEBUG ENABLED : "+ log.isDebugEnabled());
      System.out.println("CHECK ERROR ENABLED : "+ log.isErrorEnabled());
      System.out.println("CHECK INFO ENABLED : "+ log.isInfoEnabled());
      log.info("testHome.add(), Entered");
      log.debug("testHome.add(), debug Entered"); //THIS IS NOT printing
      log.warn("testHome.add(), warn Entered");

      Output:
      ------
      [STDOUT] CHECK DEBUG ENABLED : true
      [STDOUT] CHECK ERROR ENABLED : true
      [STDOUT] CHECK INFO ENABLED : true

      [testHome] testHome.add(), Entered
      15:01:41,728 WARN  [testHome] testHome.add(), warn Entered
        • 1. Re: Question on log.debug
          Chuanbao Lu Newbie

          I guess that this log4j.xml is only for the test project.  To set you project up, you have to have a log4j.xml in classpath of your project.

          • 2. Re: Question on log.debug
            Val Sw Expert
            Ok I added log4j.xml it in ear as well as jar but it didn't worked
            projectSeam.ear
               log4j.xml
               projectSeam.jar
                 log4j.xml

            I am trying to create separate file...
            a) first of all it is not creating log file "C:\\aa\\projectTest.log"
            b) secondly it prints the console output as per my last post but not printing debug statement even Debug is enabled as true..

            Please suggest what I am missing.....

            log4j.xml
            ---------
            <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
            <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">

                <appender name="appender" class="org.apache.log4j.RollingFileAppender">
                    <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
                    <param name="Target" value="System.out"/>
                    <param name="File" value="C:\\aa\\projectTest.log"/>
                      <param name="MaxFileSize" value="10000KB"/>
                      <param name="MaxBackupIndex" value="2"/>
                     <param name="Append" value="true"/>
                    <layout class="org.apache.log4j.PatternLayout">
                        <!-- The default pattern: Date Priority [Category] Message\n -->
                        <!--<param name="ConversionPattern" value="%-5p [%c{6}] %m%n"/>-->
                         <param name="ConversionPattern" value="%d [%t] %p - %m%n"/>
                    </layout>
                </appender>
               
                 <appender name="debugAppender" class="org.apache.log4j.RollingFileAppender">
                     <param name="File" value="C:\\aa\\projectTest.log"/>
                      <param name="MaxFileSize" value="10000KB"/>
                      <param name="MaxBackupIndex" value="2"/>
                     <param name="Append" value="true"/>
                     <layout class="org.apache.log4j.PatternLayout">
                       <param name="ConversionPattern" value="%d [%t] %p - %m%n"/>
                     </layout>
                   </appender>

                <!-- ############### Embedded JBoss AS #################  -->
                <category name="org.jboss">
                    <priority value="ERROR"/>
                </category>
                <category name="com.arjuna">
                    <priority value="ERROR"/>
                </category>
               
                <!-- EMB-6, JMS activation throws an error due to deployment ordering, but as there is a timeout
                and retry the tests pass. Hide the error message -->
                <category name="jboss.resource.adapter.jms.inflow.JmsActivation">
                    <priority value="ERROR"/>
                </category>

                <!-- ############### Hibernate logging ################# -->

                <category name="org.hibernate">
                    <priority value="ERROR"/>
                </category>


                <!-- ############### Seam logging ################### -->
                <category name="org.jboss.seam">
                    <priority value="WARN"/>
                </category>  
                <root>
                    <priority value="DEBUG"/>
                    <appender-ref ref="appender"/>
                </root>

            </log4j:configuration>
            • 3. Re: Question on log.debug
              Ingo Jobling Master

              If you are running JBOSS, use C:\jboss-4.2.3.GA\server\default\conf\jboss-log4j.xml

              • 4. Re: Question on log.debug
                Val Sw Expert

                Yes Ingo, we are using jboss-4.2.3.GA.
                If I use default configuration, logs are very extensive and size grows to 3 mb when I click login.. are there any steps which can reduce / bypass some default jboss logging.

                • 5. Re: Question on log.debug
                  Ingo Jobling Master

                  Hi Val, I just wanted to point out that, under JBOSS, it is not log4j.xml in your project but rather C:\jboss-4.2.3.GA\server\default\conf\jboss-log4j.xml


                  I suppose that if you want to reduce the volume of logging you would need to adapt your log4j configuration file to your requirements.