log4j two levels at once

R

Rey

Does Log4j offers setting up output for the same class/package - INFO to
console and DEBUG to file?
 
I

Ian Mills

Rey said:
Does Log4j offers setting up output for the same class/package - INFO to
console and DEBUG to file?
I would suggest you look at the log4j newsgroups but as far as I know
you can setup two appenders, one for writing to a file and one for
writing to the console, and then set different logging levels on each.
 
O

ossie.moore

You can do that and so much more. Example.. for both the default logger
and for any particular class, you can setup multiple loggers, at
different levels.

Example...

Say you have a program doing something odd and you want to debug a
particular class. You could set the default logger to "INFO" for
Console, "WARN" for file. Then, add an entry for the suspect class to
log at "DEBUG" for Console. This way, you'd see DEBUG messages on the
console for that particular class. Heck, you could even send DEBUG
level logging for a particular class to say syslog while having another
class send DEBUG to another file. You can also vary the format of the
log messages from appender to appender.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top