You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Nitin Kumar Gupta <ni...@gmail.com> on 2011/05/17 17:33:09 UTC
is it possible to have different log level for same package
suppose I have a package com.foo.hello ,
can I define log level and appender such that error logs goes to one file
and all other (even including error, if possible) goes to another file.
I tried as follows, but last one is always overwriting first one
log4j.logger.com.foo.hello=ERROR, FOO_1
log4j.logger.com.foo.hello=DEBUG, FOO_2
and appender as
log4j.appender.FOO_1=org.apache.log4j.RollingFileAppender
log4j.appender.FOO_1.File=../log/foo_error.log
&
log4j.appender.FOO_2=org.apache.log4j.RollingFileAppender
log4j.appender.FOO_2.File=../log/foo_all.log
Can someone please help me on that?
Thanks a ton
Nitin
--
View this message in context: http://old.nabble.com/is-it-possible-to-have-different-log-level-for-same-package-tp31638492p31638492.html
Sent from the Log4j - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org
RE: is it possible to have different log level for same package
Posted by Bender Heri <hb...@ergonomics.ch>.
I am not sure about properties configuration. But with xml configuration I would do:
- define one logger (your package name, level debug)
- assign two appenders to this logger:
- appender1: with level range filter error and higher
- appender2: without level range filter
Heri
> -----Original Message-----
> From: Nitin Kumar Gupta [mailto:nitinkumargupta@gmail.com]
> Sent: Tuesday, May 17, 2011 5:33 PM
> To: log4j-user@logging.apache.org
> Subject: is it possible to have different log level for same package
>
>
> suppose I have a package com.foo.hello ,
>
> can I define log level and appender such that error logs goes
> to one file and all other (even including error, if possible)
> goes to another file.
>
> I tried as follows, but last one is always overwriting first one
>
> log4j.logger.com.foo.hello=ERROR, FOO_1
> log4j.logger.com.foo.hello=DEBUG, FOO_2
>
> and appender as
>
> log4j.appender.FOO_1=org.apache.log4j.RollingFileAppender
> log4j.appender.FOO_1.File=../log/foo_error.log
> &
> log4j.appender.FOO_2=org.apache.log4j.RollingFileAppender
> log4j.appender.FOO_2.File=../log/foo_all.log
>
> Can someone please help me on that?
>
> Thanks a ton
> Nitin
>
> --
> View this message in context:
> http://old.nabble.com/is-it-possible-to-have-different-log-lev
> el-for-same-package-tp31638492p31638492.html
> Sent from the Log4j - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org
Re: is it possible to have different log level for same package
Posted by Curt Arnold <ca...@apache.org>.
Set the logger's level to the lower level and one of the appenders to a higher level. The event will get pass the check on the logger and will pass the check on one of the appenders and not the other.
log4j.logger.com.foo.hello=DEBUG,FOO_1,FOO_2
log4j.appender.FOO_1.threshold=ERROR
On May 17, 2011, at 10:33 AM, Nitin Kumar Gupta wrote:
>
> suppose I have a package com.foo.hello ,
>
> can I define log level and appender such that error logs goes to one file
> and all other (even including error, if possible) goes to another file.
>
> I tried as follows, but last one is always overwriting first one
>
> log4j.logger.com.foo.hello=ERROR, FOO_1
> log4j.logger.com.foo.hello=DEBUG, FOO_2
>
> and appender as
>
> log4j.appender.FOO_1=org.apache.log4j.RollingFileAppender
> log4j.appender.FOO_1.File=../log/foo_error.log
> &
> log4j.appender.FOO_2=org.apache.log4j.RollingFileAppender
> log4j.appender.FOO_2.File=../log/foo_all.log
>
> Can someone please help me on that?
>
> Thanks a ton
> Nitin
>
> --
> View this message in context: http://old.nabble.com/is-it-possible-to-have-different-log-level-for-same-package-tp31638492p31638492.html
> Sent from the Log4j - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org