3 Replies Latest reply on Feb 8, 2008 10:51 AM by jaikiran

    separating Hibernate and Struts logs

    babygodzilla

      Hello people,

      So I have my app running on JBoss, and using Hibernate and Struts as well. I was wondering if its possible to have separate logs, one for Hibernate and one for Struts, using log4j? If so, how do I do it?

      thank you!

        • 1. Re: separating Hibernate and Struts logs
          jaikiran

          Yes it's possible. Something like this (just an example, the syntax and other stuff might be incorrect):

          <appender name="HIB_APPENDER" class="org.apache.log4j.FileAppender">
           <param name="File" value="D:/log/HibernateLogs.log"/>
           <param name="Append" value="false"/>
          
           <layout class="org.apache.log4j.PatternLayout">
           <param name="ConversionPattern" value="%d{ISO8601} %-5p [%c] %m%n"/>
           </layout>
           </appender>
          
          
          
          
          <appender name="STRUTS_APPENDER" class="org.apache.log4j.FileAppender">
           <param name="File" value="D:/log/StrutsLogs.log"/>
           <param name="Append" value="false"/>
          
           <layout class="org.apache.log4j.PatternLayout">
           <param name="ConversionPattern" value="%d{ISO8601} %-5p [%c] %m%n"/>
           </layout>
           </appender>
          
           <category name="org.hibernate">
           <appender-ref ref="HIB_APPENDER"/>
           </category>
          
           <category name="org.apache.struts">
           <appender-ref ref="STRUTS_APPENDER"/>
           </category>


          • 2. Re: separating Hibernate and Struts logs
            babygodzilla

            thanks! the hibernate part works, but the Struts one did not. i suspect its because there is this in jboss-log4j.xml


            <!-- Limit the org.apache category to INFO as its DEBUG is verbose -->
            <category name="org.apache">
            <priority value="INFO"/>
            </category>


            my guess is since org.apache.struts2 is a subset of org.apache, the configuration you gave me did not work. can we make a category within a category?

            • 3. Re: separating Hibernate and Struts logs
              jaikiran

              I actually have something like this in my log4j file:

              <category name="org.jboss">
               <priority value="WARN"/>
               </category>
              
               <category name="org.jboss.system">
               <priority value="INFO" />
               </category>


              I see logs being generated for org.jboss.system (which is a sub-package under org.jboss) at INFO level and that for all other classes of org.jboss (and its subfolders) being generated at WARN level. How does your configuration look like after the changes you have done?