What I have: 1) Three applications/modules using log4j logging and want to log to three different logfiles 2) These three applications have one logger defined for each (log1, log2, log3) with different levels for each logger. 3) I have defined 3 appenders apndr1, apndr2, apndr3 and have association defined between log1->apndr1, log2->apndr2 and log3->apndr3 4) I would like to have a separate log file (fourth one) which will have ONLY 'FATAL' messages from all three applications. 5) Hence I defined root logger and associated appender4 to it for level="fatal" 6) I thought this would do what I want (as explained in #4). But it doesn't seem to work. What happens is root appender logs all the messages from lowest level (out of 3) onwards for all 3 loggers. Essentially it looks like root has no regard to it's own level specified. The lowest level value of all 3 categories is what root logger uses? 7) I tried different combinations of additivity attribute too. Could not succeed.. 8) I tried using logger for "app" instead of root logger. Could not succeed... 9) I am using log4j_1_2_6 and xmlconfiguration file
Can anyone please let me know if I am doing something wrong, or there is workaround or this is not possible? Here is the part of xmlconfiguration file I am using: <logger name="app.mod1"> <level value="debug"/> <appender-ref ref="firstLogFile"/> </logger> <logger name="app.mod2"> <level value="info"/> <appender-ref ref="secondLogFile"/> </logger> <logger name="app.mod3"> <level value="warn"/> <appender-ref ref="thirdLogFile"/> </logger> <root> <level value="fatal" /> <appender-ref ref="fourthLogFile" /> </root> Thank you for your help, Sudhir