2 Replies Latest reply on Apr 16, 2010 7:06 AM by Jose Antonio

    Setting log level lower than threshold for certain classes

    Jose Antonio Newbie

      I'm using JBoss 4.2.3GA and I want to get DEBUG messages from classes in package "com.something" and INFO for everything else. Can I do that? I tried with this:

       

      <appender name="FILE">
            <errorHandler/>
            <param name="File" value="${jboss.server.log.dir}/server.log"/>
            <param name="Append" value="false"/>
            <param name="Threshold" value="INFO"/>
       
            <!-- Rollover at midnight each day -->
            <param name="DatePattern" value="'.'yyyy-MM-dd"/>
       
            <!-- Rollover at the top of each hour
            <param name="DatePattern" value="'.'yyyy-MM-dd-HH"/>
            -->
       
            <layout>
               <!-- The default pattern: Date Priority [Category] Message\n -->
               <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
       
               <!-- The full pattern: Date MS Priority [Category] (Thread:NDC) Message\n
               <param name="ConversionPattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
                -->
            </layout>
         </appender>
       
         <category name="com.something">
            <priority value="DEBUG"/>
         </category>
      

       

      But I only get INFO messages and my DEBUG messages are not printed. I know I could set the Threshold element to DEBUG but this gives me too much information and I'd have to create <category> configurations for every other package in the system except my desired classes, and, as I don't know all the applications installed in the system, that would be impossible.

      Is there a way to get what I want?

        • 1. Re: Setting log level lower than threshold for certain classes
          jaikiran pai Master

          Jose Antonio wrote:

           

          I know I could set the Threshold element to DEBUG but this gives me too much information and I'd have to create <category> configurations for every other package in the system except my desired classes, and, as I don't know all the applications installed in the system, that would be impossible.

          Is there a way to get what I want?

          Set the Threshold of the appender to DEBUG and then set the "root logger" priority level to INFO. That way, you won't have to create multiple categories and sepcify the levels:

           

          <appender name="FILE">
          ...
                <param name="Threshold" value="INFO"/>
          ...
          </appender>
          
          <category name="com.something">
                <priority value="DEBUG"/>
             </category>
          
          <root>
                <priority value="INFO"/>
                <appender-ref ref="CONSOLE"/>
                <appender-ref ref="FILE"/>
             </root>