logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Wataru Fukushima <w.fukush...@pfu.fujitsu.com>
Subject Re: Way to set another log file for one category with different log level
Date Thu, 07 Nov 2002 07:16:19 GMT
Thank you for your information, Jake.

On Tue, 05 Nov 2002 06:20:45 -0600, according to the article
"Re: Way to set another log file for one category with  different log level"
Jacob Kjome <hoju@visi.com> wrote:

> I guess you could set up two appenders which are referenced in the root 
> logger and then have a filter in each appender specifying which log level 
> to output.

Actually I did not know that each appender threshold can be set by specifying
  log4j.appender.xxxxx.threshold=XXXX
in log4j.properties.

> >How can I write log4j.proerties to output two different log files for one
> >category when each threshold is different?

Finally I made it by setting log4j.properties as follows:

log4j.rootCategory=DEBUG
log4j.category.log=DEBUG, log, errorlog
log4j.appender.log=org.apache.log4j.RollingFileAppender
log4j.appender.log.layout=org.apache.log4j.PatternLayout
log4j.appender.log.layout.ConversionPattern=%d %F %L %-5p %m%n
log4j.appender.log.File=debug.log
log4j.appender.errorlog=org.apache.log4j.RollingFileAppender
log4j.appender.errorlog.threshold=ERROR
log4j.appender.errorlog.layout=org.apache.log4j.PatternLayout
log4j.appender.errorlog.layout.ConversionPattern=%d %F %L %-5p %m%n
log4j.appender.errorlog.File=error.log

I could not use root logger since I've used other appenders to write other
logs to other files.

> >In other words, I want two output:
> >   - error.log     for output errors only
> >   - debug.log     for output all logs
> >
> >The Java code is something like this:
> >
> >   Logger log = Logger.getLogger("log")
> >   log.error("error message");
> >   log.warn("warning message");
> >
> >
> >And I want those two files will be:
> >
> ><error.log>
> >   error message
> >
> ><debug.log>
> >   error message
> >   warning message

-------------------------------
Wataru Fukushima
PFU LIMITED


--
To unsubscribe, e-mail:   <mailto:log4j-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:log4j-user-help@jakarta.apache.org>


Mime
View raw message