0

I've tried to search for something similar and yet to find. I'm trying to configure 2 log files, one that is more chatty, and one that is more quiet. In my main log file, I want WARN and up, but have configured several packages to be at the DEBUG or INFO levels. I have a second file that I want only ERROR messages with the exception of one class at a DEBUG level. Configuration is attached, but I never see the CLazz debug in the quiet log. Thoughts?

<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<appender name="MAINLOGFILE" class="org.apache.log4j.RollingFileAppender">
    <param name="File" value="/var/log/jboss/main.log"/>
    <param name="Append" value="true"/>
    <param name="MaxFileSize" value="5000KB"/>
    <param name="MaxBackupIndex" value="7"/>
    <layout class="org.apache.log4j.PatternLayout">
        <param name="ConversionPattern" value="%d{DATE} %-5p %-15c{1} [%x]: %m%n"/>
    </layout>
</appender>
<appender name="QUIETFILE" class="org.apache.log4j.RollingFileAppender">
    <param name="File" value="/var/log/jboss/quiet.log"/>
    <param name="Append" value="true"/>
    <param name="MaxFileSize" value="5000KB"/>
    <param name="MaxBackupIndex" value="7"/>
    <param name="Threshold" value="ERROR"/>
    <layout class="org.apache.log4j.PatternLayout">
        <param name="ConversionPattern" value="%d{DATE} %-5p %-15c{1} [%x]: %m%n"/>
    </layout>
</appender>

<category name="com.foo.bar">
    <priority value="info"/>
    <appender-ref ref="MAINLOGFILE"/>
</category>

<!-- Several other INFO and DEBUG package here -->

<category name="com.foo.bar.biz.Clazz">
    <priority value="debug"/>
    <appender-ref ref="QUIETFILE"/>
</category>

<root>
    <param name="Level" value="warn"/>
    <appender-ref ref="MAINLOGFILE"/>
    <appender-ref ref="QUIETFILE"/>
</root>

ksdaly
  • 5
  • 1
  • 7
  • I think your question is answered http://stackoverflow.com/questions/8653548/log4j-priority-value-and-param-name-concept-explanation – Gajendra Naidu Dec 16 '15 at 13:47
  • I understand the purpose of the threshold and priority settings, however, I want the quiet log to contain ERROR and above except for one logger, which I want at DEBUG. Setting the threshold at ERROR will always exclude the DEBUG priority, but setting the threshold at DEBUG is too noisy. Trying to find that setting that overrides the threshold for one class. – ksdaly Dec 21 '15 at 13:31

1 Answers1

0

try change it to:

<category name="com.foo.bar.biz.Clazz" additivity="false">

seems like you did the same solution as explained here (without the 'additivity'):

10.3.5. Redirecting Category Output
http://docs.jboss.org/process-guide/en/html/logging.html

Victor Bouhnik
  • 198
  • 2
  • 14
  • Thanks for the info and link, I finally understand the additivity flag that I did not before. However, in my testing this did not allow any of the Clazz logging in the quiet.log file. When I changed the threshold on the QUIETFILE appender to a different threshold, I did get the logging i expected ONLY in the quiet.log, however, I got the additional logging from new logging levels. Not sure why it's not overriding the Clazz level only in that appender. Any additional thoughts? – ksdaly Dec 21 '15 at 13:26
  • Found the right mix. Removed the threshold on the appender config, added a couple new loggers for the packages I wanted errors logged and ref only the QUIETFILE appender, and removed the QUIETFILE from the root config. Seems to give me what I want. Thanks again for getting me on the right track! – ksdaly Dec 21 '15 at 13:52