4 Replies Latest reply on Dec 8, 2003 9:10 AM by Don Griffing

    log4j Configuation

    Don Griffing Newbie

      I am using JBoss 3.0.6 and am having problems controlling the logging. My objective is to have different logging levels for the CONSOLE and FILE. For the CONSOLE, I want the following levels:
      my classes: INFO
      org.jboss: WARN
      org.jboss.system.server.Server: INFO
      org.apache: WARN
      STDOUT: WARN

      For the FILE, I want:
      my classes: INFO
      org.jboss: INFO
      org.apache: INFO
      STDOUT: INFO

      When I used log4j before, I was able to establish this pattern. However, I used the PropertyConfigurator and not the DOMConfigurator. I have tried adding appender-ref to my category elements. The best result is the same message appearing multiple time in the console. The worst result has been a error about a circular reference. What am I doing wrong?

        • 1. Re: log4j Configuation
          urddd Newbie

          I'd like to know it because I have a similar problem.

          • 2. Re: log4j Configuation
            Don Griffing Newbie

            I have reviewed other Log4j documention and still have not found a solution to my original problem. Does anyone have the answer?

            • 3. Re: log4j Configuation
              urddd Newbie

              I think I've got only part of the solution:

              My solution is not really elegant but it works on JBoss 3.2.2 (the log4j config file on JBoss 3.0.6 is slightly diffrent but I think the same pattern can be applied).

              In one sentence, what I've done it to set the level into the appender and not into the category.

              In the example below I've done several things:
              - Remove root's appender-ref (they're commented)
              - Create the category whith the appenders without setting a priority value
              - Set a Threshold in the appenders.

              The consequence is that you have several appenders writting to the same output (file or console).

              In CONSOLE:
              org.jboss.varia DEBUG
              org.jboss.deployment INFO

              In FILE:
              org.jboss.varia INFO
              org.jboss.deployment DEBUG

              Working log4j.xml example on jboss 3.2.2:


              <?xml version="1.0" encoding="UTF-8"?>
              <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
              <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
              <!-- ============================== -->
              <!-- Append messages to the files -->
              <!-- ============================== -->





              <param name="DatePattern" value="'.'yyyy-MM-dd"/>










              <param name="DatePattern" value="'.'yyyy-MM-dd"/>






              <!-- ============================== -->
              <!-- Append messages to the console -->
              <!-- ============================== -->





























              <!-- ================ -->
              <!-- Limit categories -->
              <!-- ================ -->



              <appender-ref ref="FILE_INFO"/>
              <appender-ref ref="CONSOLE_DEBUG"/>



              <appender-ref ref="FILE_DEBUG"/>
              <appender-ref ref="CONSOLE_INFO"/>


              <!-- ======================= -->
              <!-- Setup the Root category -->
              <!-- ======================= -->


              <!--
              <appender-ref ref="CONSOLE"/>
              <appender-ref ref="FILE"/>
              -->


              </log4j:configuration>

              • 4. Re: log4j Configuation
                Don Griffing Newbie

                Thanks for your update. I tried following the same pattern with the JBoss 3.0.6 log4j.xml. Unfortunately, it did not work. Still looking.