I myself had a hard time to figure out
that the event triggering the SMTPAppender
has to at least be an ERROR event, i.e.
you will not get any email if the event
is with less priority than error.
To make that happen you have to write your
own EventEvaluator.
I have included the piece of code which
you can use to achieve just that. Note that
the last row in the configuration file
points out that our new EventEvaluator should
be used instead of the default one.
Lycka till!
<configuration file>
log4j.rootCategory= , mail
log4j.appender.mail=org.apache.log4j.net.SMTPAppender
[EMAIL PROTECTED]
log4j.appender.mail.From=someone
log4j.appender.mail.Subject=about
log4j.appender.mail.SMTPHost=smtp.host.com
log4j.appender.mail.layout=org.apache.log4j.PatternLayout
log4j.appender.mail.layout.ConversionPattern=%d [%t]
%-5p %c - %m%n
log4j.appender.mail.EvaluatorClass=MailEventEvaluator
</configuration file>
<MailEventEvaluator.java>
import org.apache.log4j.Priority;
import org.apache.log4j.spi.TriggeringEventEvaluator;
import org.apache.log4j.spi.LoggingEvent;
public class MailEventEvaluator implements
TriggeringEventEvaluator
{
public boolean isTriggeringEvent (LoggingEvent
event)
{
return event.priority.isGreaterOrEqual
(Priority.DEBUG);
}
}
</MailEventEvaluator.java>
--- "Ahlin, Mattias"
<[EMAIL PROTECTED]> wrote:
> Hi everyone!
>
> I can't figure out how to use the SMTPAppender.
>
> Is there anyone that have a short example of
> how to initialize it?
>
>
> --Mattias Ahlin
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
>
__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - Buy the things you want at great prices.
http://auctions.yahoo.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]