Can we control the logging level to class level instead of package level?
Hi, Can I do something like this : For specific class in certain package, don't log the event using specific appender while allowing other classes in the same package to do that? Thanks. Song - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Can we control the logging level to class level instead of package level?
Certainly - you could define a logger with the name of the class itself, then effectively squelch it: via DOMConfigurator: logger name=com.mycompany.myproduct.MyClass additivity=false level value=FATAL/ !-- I believe you can also specify NONE -- /logger logger name=com.mycompany.myproduct level value=DEBUG/ appender-ref ref=SomeAppender/ /logger root level value=DEBUG/ appender-ref ref=MyAppender/ /root You can achieve similar results with PropertyConfigurator (see the online log4j manual) or, shamelessplug check out The Complete Log4j Manual by Ceki Gulcu /shamelessplug -Scott Heaberlin -Original Message- From: news [mailto:[EMAIL PROTECTED] On Behalf Of Song Sent: Monday, December 08, 2003 7:48 PM To: [EMAIL PROTECTED] Subject: Can we control the logging level to class level instead of package level? Hi, Can I do something like this : For specific class in certain package, don't log the event using specific appender while allowing other classes in the same package to do that? Thanks. Song - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Can we control the logging level to class level instead of package level?
Scott Heaberlin [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Certainly - you could define a logger with the name of the class itself, then effectively squelch it: via DOMConfigurator: logger name=com.mycompany.myproduct.MyClass additivity=false level value=FATAL/ !-- I believe you can also specify NONE -- /logger Thanks a lot! shamelessplug check out The Complete Log4j Manual by Ceki Gulcu /shamelessplug I already bought it and it's on the way. Song -Scott Heaberlin -Original Message- From: news [mailto:[EMAIL PROTECTED] On Behalf Of Song Sent: Monday, December 08, 2003 7:48 PM To: [EMAIL PROTECTED] Subject: Can we control the logging level to class level instead of package level? Hi, Can I do something like this : For specific class in certain package, don't log the event using specific appender while allowing other classes in the same package to do that? Thanks. Song - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Can we control the logging level to class level instead of package level?
It seems that root config will override the logger config, is this true? Give the following configuration, I still see error event from EventLoggerSessionEJB logged into database. But if I change the logging level from 'INFO' to 'FATAL', the event will not be logged. Here is part of my log4j config: logger name=com.tumbleweed.messenger.server.ejb.impl.EventLoggerSessionEJB level value=INFO/ appender-ref ref=CONSOLE/ /logger root appender-ref ref=CONSOLE/ appender-ref ref=FILE/ appender-ref ref=JDBC/ appender-ref ref=NTEventLog/ /root Thanks. Song Scott Heaberlin [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Certainly - you could define a logger with the name of the class itself, then effectively squelch it: via DOMConfigurator: logger name=com.mycompany.myproduct.MyClass additivity=false level value=FATAL/ !-- I believe you can also specify NONE -- /logger logger name=com.mycompany.myproduct level value=DEBUG/ appender-ref ref=SomeAppender/ /logger root level value=DEBUG/ appender-ref ref=MyAppender/ /root You can achieve similar results with PropertyConfigurator (see the online log4j manual) or, shamelessplug check out The Complete Log4j Manual by Ceki Gulcu /shamelessplug -Scott Heaberlin -Original Message- From: news [mailto:[EMAIL PROTECTED] On Behalf Of Song Sent: Monday, December 08, 2003 7:48 PM To: [EMAIL PROTECTED] Subject: Can we control the logging level to class level instead of package level? Hi, Can I do something like this : For specific class in certain package, don't log the event using specific appender while allowing other classes in the same package to do that? Thanks. Song - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Can we control the logging level to class level instead of package level?
you'll need to switch additivity off for the logger you want disabled, otherwise the LoggingEvent gets passed up the logger hierarchy to the root logger The short manual has info on this: http://jakarta.apache.org/log4j/docs/manual.html (see the bit on additivity) But when you get Ceki's book, that'll help even more. Paul On Tue, 2003-12-09 at 13:02, Song wrote: It seems that root config will override the logger config, is this true? Give the following configuration, I still see error event from EventLoggerSessionEJB logged into database. But if I change the logging level from 'INFO' to 'FATAL', the event will not be logged. Here is part of my log4j config: logger name=com.tumbleweed.messenger.server.ejb.impl.EventLoggerSessionEJB level value=INFO/ appender-ref ref=CONSOLE/ /logger root appender-ref ref=CONSOLE/ appender-ref ref=FILE/ appender-ref ref=JDBC/ appender-ref ref=NTEventLog/ /root Thanks. Song Scott Heaberlin [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Certainly - you could define a logger with the name of the class itself, then effectively squelch it: via DOMConfigurator: logger name=com.mycompany.myproduct.MyClass additivity=false level value=FATAL/ !-- I believe you can also specify NONE -- /logger logger name=com.mycompany.myproduct level value=DEBUG/ appender-ref ref=SomeAppender/ /logger root level value=DEBUG/ appender-ref ref=MyAppender/ /root You can achieve similar results with PropertyConfigurator (see the online log4j manual) or, shamelessplug check out The Complete Log4j Manual by Ceki Gulcu /shamelessplug -Scott Heaberlin -Original Message- From: news [mailto:[EMAIL PROTECTED] On Behalf Of Song Sent: Monday, December 08, 2003 7:48 PM To: [EMAIL PROTECTED] Subject: Can we control the logging level to class level instead of package level? Hi, Can I do something like this : For specific class in certain package, don't log the event using specific appender while allowing other classes in the same package to do that? Thanks. Song - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]