Looking at the example code below, I'm a little confused as to how/where the
setSMTPAppender would get called?  Secondly, is it feasible to do something
like the below where the "foo" value gets set from a request parameter?  Can
someone please enlighten me??  Thanks for all the help.

public boolean isTriggeringEvent(LoggingEvent event)  {
  if (event.level.isGreaterOrEqual(Level.FATAL)) {
    return true;
  } else {
    if (app != null) {
      if(MDC.get("foo").equals("bar")) {
        // reset the message content
        app.setBufferSize(0);
        app.setBufferSize(size);
      }
  }
}



----- Original Message ----- 
From: "Roth Marcel" <[EMAIL PROTECTED]>
To: "Log4J Users List" <[EMAIL PROTECTED]>
Sent: Monday, January 26, 2004 12:00 PM
Subject: Re: SMTPAppender


> Hi Jeb,
>
> a way to do this is via implementing the TriggeringEventEvaluator.
> Try something like this
> cheers,
> Marcel
>
>
/***********************************************************************
>      * SMTP Trigger Event Evaluator
>      */
>     private static class SMTPTriggerEval implements
TriggeringEventEvaluator {
>         SMTPAppender app;
>         public void setSMTPAppender(SMTPAppender app) {
>             this.app = app;
>         }
>         public boolean isTriggeringEvent(LoggingEvent event)  {
>             if (event.level.isGreaterOrEqual(Level.FATAL)) {
>                 return true;
>             } else {
>                 if (app != null) {
>                     // reset the message content
>                     int size = app.getBufferSize();
>                     app.setBufferSize(0);
>                     app.setBufferSize(size);
>                 }
>                 return false;
>             }
>         }
>     }
>
>
>
>
>
> Quoting Jeb Scarbrough <[EMAIL PROTECTED]>:
>
> > I am wanting to send all logs messags via email when i send POST a
> > certain
> > key-value pair to my servlet.  In essence, allowing me to see a debug
> > log of
> > one specific request.  I'm new with log4j and havent found much on this
> > in
> > the archives.  has anyone tried to do this? is it possible?  would what
> > be a
> > good starting point to accomplishing something like this?
> >
> > Thanks.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
>
>
>
> Marcel Roth
> Technology Consultant
> Enterprise CRM
> _______________________________
> Softlab AG
> Kanalstrasse 31
> CH-8152 Glattbrugg
> Switzerland
> Telefon    +41 1 809 41 57
> Telefax    +41 1 809 41 42
> Mobile    +41 76 420 02 07
> E-Mail    mailto:[EMAIL PROTECTED]
> Homepage:  http://www.softlab.ch
> _______________________________
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to