Hello,
Need help on configuring log4j.
Let's say, we have following logger :
and this log4j configuration file :
log4j.rootLogger=ERROR, stdout
log4j.category.a=TRACE, a
##### STDOUT
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%-5p [%d{dd MM yyyy HH:mm:ss.SSS}] %l - %m%n
##### a
log4j.appender.a=org.apache.log4j.DailyRollingFileAppender
log4j.appender.a.File=c:\\logs\\a.log
log4j.appender.a.layout=org.apache.log4j.PatternLayout
log4j.appender.a.layout.ConversionPattern=%-5p [%d{dd MM yyyy HH:mm:ss.SSS}] %l - %m%n
log4j.appender.a.DatePattern='.'yyyy-MM-dd
log4j.appender.a.ImmediateFlush=true
The
test code looks like this :
a.debug("debugA");
a.error("errorA");
I see both of these lines in the file created AND in stdout :
But I don't want this line :
to appear in stdout.
What I want is, I've several categories, each logging to different files.
But when an error occurs, I want the stacktrace to appear in the stdout file (SystemOut.log) as well.
Is there a way of accomplishing this WITHOUT writing code looking similar to this :
Is there a way to establish this through the configuration file ?