Markus, I have a logging system where only fatal errors are sent through an SMTP handler and mailed to someone. All messages are logged to the console.
To do this my config file looks like this: log4j.rootLogger=debug, stdout,mail log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n #Use the SMTPAppender for mail log4j.appender.mail=org.apache.log4j.net.SMTPAppender [EMAIL PROTECTED] [EMAIL PROTECTED] log4j.appender.mail.Subject=A Fatal Harness Error Occurred log4j.appender.mail.SMTPHost=myMailHost log4j.appender.mail.layout=org.apache.log4j.PatternLayout log4j.appender.mail.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n #implement this class to only react to fatal or above errors log4j.appender.mail.EvaluatorClass=com.adam.utils.MailEventEvaluator Now we need to implement com.adam.utils.MailEventEvaluator which will cause the SMTPHandler to only be used when we come across a fatal level message. package com.adam.utils; import org.apache.log4j.Level; import org.apache.log4j.spi.TriggeringEventEvaluator; import org.apache.log4j.spi.LoggingEvent; /** * This class isn used to send fatal error messages to a mail server as per * Log4J TriggeringEventEvaluator functionality */ public class MailEventEvaluator implements TriggeringEventEvaluator { public boolean isTriggeringEvent (LoggingEvent event) { return event.level.isGreaterOrEqual(Level.FATAL); } } Hope this helps, Adam -----Original Message----- From: Markus Spath [mailto:[EMAIL PROTECTED]] Sent: Tuesday, February 26, 2002 10:26 AM To: [EMAIL PROTECTED] Subject: appenders in different levels? [newbie] Hi, is it possible to add appenders to category definitions listening to different log-levels (sorry if my terminology is awkward) e.g. to print only errors of a given Category to the ConsoleAppender, but printing all messages to a RolingFileAppender? (a workaround would be to define a seperate Category) any examples (*.lcf) would be very helpful. thanks, Markus -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>