-
1. Re: log4j config file behaviour
peterj Jul 7, 2009 2:59 PM (in response to brettcave)Setting a priority for a category limits which log messages are forwarded to the appenders. Thus, for both com.mycompany.package1 and com.mycompany.package2 only ERROR messages get logged.
The root definition identifies the appenders to use for all log messages, thus all messages are sent to SMTP, CONSOLE and FILE. In addition, log messages for com.mycompany.package1 are sent a second time to CONSOLE - the messages were sent the first time to CONSOLE because all categories inherit from root. This point confused me the first time I ran into it also. -
2. Re: log4j config file behaviour
brettcave Jul 8, 2009 4:30 AM (in response to brettcave)ah, ok makes sense.
There isnt a way to override appenders on a per-category basis then? Ideally, I want to log ERROR to SMTP, CONSOLE and FILE for everything except for 1 or 2 categories, which I only want logged to CONSOLE / FILE - would have to have a more verbose config to achieve this then? -
3. Re: log4j config file behaviour
jaikiran Jul 8, 2009 4:40 AM (in response to brettcave)"brettcave" wrote:
Ideally, I want to log ERROR to SMTP, CONSOLE and FILE for everything except for 1 or 2 categories, which I only want logged to CONSOLE / FILE
The "additivity" flag on a category will help in achieving this. Ex:<category name="com.mycompany.package1" additivity="false"> <priority value="ERROR" /> <appender-ref ref="CONSOLE" /> </category> <category name="com.mycompany.package2"> <priority value="ERROR" /> </category> <root> <priority value="INFO" /> <appender-ref ref="SMTP" /> <appender-ref ref="CONSOLE" /> <appender-ref ref="FILE" /> </root>
Here com.mycompany.package1 will log only to the CONSOLE because the additivity flag is set to false. That flag can be used to specify that the log messages of a particular category are not to be propagated to the parent categories (the root in this case). -
4. Re: log4j config file behaviour
brettcave Jul 8, 2009 8:17 AM (in response to brettcave)instant reply seems broken :( or theres something funky in my cache.
-
5. Re: log4j config file behaviour
brettcave Jul 8, 2009 8:18 AM (in response to brettcave)thanks jaikiran