4 Replies Latest reply on Sep 20, 2012 2:38 AM by everyman

    Logging in JBoss 5.1

    everyman

      Hi,

       

      I have problem with logging in Jboss 5.1.

      I would like to have 2 log files. One file with only Jboss info(server.log) and second file with only my application info

       

      My jboss-log4j.xml

       

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

      <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

      <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">

       

       

         <appender name="FILE" class="org.jboss.logging.appender.DailyRollingFileAppender">

            <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>

            <param name="File" value="${jboss.server.log.dir}/server.log"/>

            <param name="Append" value="true"/>

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

            <layout class="org.apache.log4j.PatternLayout">   

               <param name="ConversionPattern" value="%d %-5p [%c] (%t) %m%n"/>

            </layout>

         </appender>  

         <appender name="MyAppLog" class="org.apache.log4j.FileAppender">

            <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"></errorHandler>

            <param name="Append" value="false"/>

            <param name="File" value="${jboss.server.home.dir}/log/MyApp.log"/>

            <layout class="org.apache.log4j.PatternLayout">

              <param name="ConversionPattern" value="%d %-5p %c{1} %m%n"/>

            </layout>

            <filter class="org.jboss.logging.filter.TCLFilter">

               <param name="AcceptOnMatch" value="true"/>

               <param name="DeployURL" value="MyApp.war"/>

            </filter>   

            <filter class="org.apache.log4j.varia.DenyAllFilter"></filter>

         </appender>

         <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">

            <param name="Target" value="System.out"/>

            <param name="Threshold" value="INFO"/>

            <layout class="org.apache.log4j.PatternLayout">

               <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>

            </layout>

         </appender>

        

         <category name="org.apache">

            <priority value="INFO"/>

         </category>

         <category name="jacorb">

            <priority value="WARN"/>

         </category>

         <category name="javax.enterprise.resource.webcontainer.jsf">

           <priority value="INFO" class="org.jboss.logging.log4j.JDKLevel"/>

         </category>

         <category name="org.jgroups">

            <priority value="WARN"/>

         </category>

         <category name="org.quartz">

            <priority value="INFO"/>

         </category>

         <category name="com.sun">

            <priority value="INFO"/>

         </category>

         <category name="sun">

            <priority value="INFO"/>

         </category>

         <category name="javax.xml.bind">

            <priority value="INFO"/>

         </category>

         <category name="org.jboss.management">

            <priority value="INFO"/>

         </category>

         <category name="facelets.compiler">

            <priority value="WARN"/>

         </category>

         <category name="org.ajax4jsf.cache">

            <priority value="WARN"/>

         </category>

         <category name="org.rhq">

            <priority value="WARN"/>

         </category>

         <category name="org.jboss.seam">

            <priority value="WARN"/>

         </category>

         </category>

         <category name="org.jboss.serial">

            <priority value="INFO"/>

         </category>

         <category name="com.myapp">

            <priority value="DEBUG"/>

                  <appender-ref ref="MyAppLog"/>

         </category>

         <root>

            <priority value="${jboss.server.log.threshold}"/>

            <appender-ref ref="CONSOLE"/>

            <appender-ref ref="FILE"/>

                  <appender-ref ref="MyAppLog"/>

         </root>

      </log4j:configuration>

        • 1. Re: Logging in JBoss 5.1
          peterj

          You never said what is wrong with the configuration you have, so I will make a guess:

           

          You are seeing JBoss AS entries in your log file. The reasons for that is you placed your appender in <root>, thus all categories will log to your appender.

           

          If I guessed wrong, kindly explain what the problem is (what you are seeing that you did not expect or did not want).

          • 2. Re: Logging in JBoss 5.1
            everyman

            In server.log I see all info (from JBoss and application), in MyApp.log I see info only from application. I would like to see info from JBoss only in server.log and info from application only in MyApp.log

            • 3. Re: Logging in JBoss 5.1
              peterj

              Mariusz Bozek wrote:

               

              I would like to see info from JBoss only in server.log

              This is much more difficult. You have to understand that categories are arranged in a hierarchy with <root> being the base of the hierarchy. All categories inherit from their parents, thus every category inherits the directives to output to the CONSOLE and FILE  appenders. To not do that, you must remove all appenders from <root> and copy them to all of the other categories. In addition, you might need to create base categories for "org" and "com" to catch all of the things that are currently being logged.

               

              I suspect that there are other ways to do this also, a good log4j reference or book would give you more ideas.

              Mariusz Bozek wrote:

               

              I would like to see info ... from application only in MyApp.log

              I already gave you the solution to this.

              1 of 1 people found this helpful
              • 4. Re: Logging in JBoss 5.1
                everyman

                Thanks