[logback-user] SMTPAppender and JaninoEventEvaluator not working as expected

Thorsten Schöning tschoening at am-soft.de
Tue Jul 9 08:53:18 CEST 2019


Hi all,

I have an SMTPAppender in place which should send mails in case of log
level WARN as well instead of only ERROR. That works properly with the
following expression and a custom implementation checking the log
level:

> <evaluator class="de.am_soft.util.logging.logback.OnWarnEvaluator" />

I have an additional SMTPAppender which should recognize the
WARN-check as well, but check additional aspects of the logger and the
log message. I thought that using an ADDITIONAL filter is the correct
thing to do:

> <evaluator class="de.am_soft.util.logging.logback.OnWarnEvaluator" />
> <filter class="ch.qos.logback.core.filter.EvaluatorFilter">
>       <evaluator class="ch.qos.logback.classic.boolex.JaninoEventEvaluator">
>               <expression>
>                       return  logger.endsWith(".emptyPacket") ||
>                                       ((throwableProxy != null)               &&
>                                         throwableProxy.getMessage().contains("missing collectors"));
>               </expression>
>       </evaluator>
> 
>       <onMatch>ACCEPT</onMatch>
>       <onMismatch>DENY</onMismatch>
> </filter>

But that doesn't work, the receiver gets ALL mails with log level
WARN, the additional filter doesn't seem to be applied. So I simply
removed OnWarnEvaluator because I thought that the filter itself
should be enough to decide, but that doesn't work as well. The
receiver gets only mails with log level ERROR now.

So how do OnWarnEvaluator and filter interact? Which one gets executed
first or even at all? Regarding my tests it seems that only
OnWarnEvaluator gets executed.

Does the filter need to check the log level as well? Wouldn't make
much sense to me, because the appender doesn't care about which things
are checked within the filter, only about its results.

Thanks for any clarifications!

Mit freundlichen Grüßen,

Thorsten Schöning

-- 
Thorsten Schöning       E-Mail: Thorsten.Schoening at AM-SoFT.de
AM-SoFT IT-Systeme      http://www.AM-SoFT.de/

Telefon...........05151-  9468- 55
Fax...............05151-  9468- 88
Mobil..............0178-8 9468- 04

AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
AG Hannover HRB 207 694 - Geschäftsführer: Andreas Muchow



More information about the logback-user mailing list