logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Curt Arnold <carn...@apache.org>
Subject Re: SMTPAppender ignores Threshold value
Date Wed, 04 Jul 2007 20:22:00 GMT

On Jul 4, 2007, at 1:28 PM, jaikiran pai wrote:

> Recently i saw a post on one of the forums where a user complained  
> that the SMTPAppender does not take into account the Threshold  
> value that is specified in the configuration. By default, the  
> appender logs only events which have a level eqaul to or higher  
> than ERROR. Here's  one post in this mailing list which proves the  
> same:
> http://www.mail-archive.com/log4j-user@jakarta.apache.org/ 
> msg03741.html
> This appears to be because of the DefaultEvaluator inside the  
> SMTPAppender which has the following logic:
> class DefaultEvaluator implements TriggeringEventEvaluator {
>   /**
>      Is this <code>event</code> the e-mail triggering event?
>      <p>This method returns <code>true</code>, if the event level
>      has ERROR level or higher. Otherwise it returns
>      <code>false</code>. */
>   public
>   boolean isTriggeringEvent(LoggingEvent event) {
>     return event.getLevel().isGreaterOrEqual(Level.ERROR);
>   }
> Users who want to log messages with levels lesser than ERROR,  
> currently have to configure their *own implementation* of the  
> TriggeringEventEvaluator. This doesnt seem right. I would prefer  
> the DefaultEvaluator  take into account the Threshold value that  
> has been specified in the log4j configuration file
>  instead of hardcoding the Level.ERROR. After all, that's what the  
> Threshold attribute is meant to do.
> The fix (if i can call it so) appears simple - just have to pass on  
> the Threshold value from the appender to the DefaultEvaluator. Let  
> me know if anyone wants me to send a patch for this.
> regards,
> -Jaikiran

The threshold and trigger are two different things.  The threshold  
determines what events go into the mail message, the trigger  
determines when the message is sent.  If you set threshold to INFO  
and trigger to ERROR, when there is an ERROR you will get an email  
with all INFO and high level messages since the last error.

I don't have time to review it at the moment, but will get back to  
you later.

To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org

View raw message