SMTPAppender with multiple filters

Hi there, I'm having an issue with using multiple filters as you had outlined in a previous post: <appender name="SQL_TRANSACTION_DELAY_EMAIL" class="ch.qos.logback.classic.net.SMTPAppender"> <filter class="ch.qos.logback.classic.filter.LevelFilter"> <level>WARN</level> <onMatch>NEUTRAL</onMatch> <onMismatch>DENY</onMismatch> </filter> <filter class="com.annadaletech.taxfree.kioskapp.util.SQLTransactionDelayFilter"> <transactionDelayText>running time (millis)</transactionDelayText> </filter> ... </appender> The first filter is looking for any log entry marked as [WARN ] and the second checks this message for my own user defined value and whether or not the email needs to be sent. However, though the second filter code is being accessed, the email is not passed from an ACCEPT filterReply. I've also read somewhere that apparently the SMTPAppender wont send an email unless its catching an ERROR message. If so, how can I alter this? Your thoughts appreciated, Ray. -- View this message in context: http://logback.10977.n7.nabble.com/SMTPAppender-with-multiple-filters-tp1186... Sent from the Users mailing list archive at Nabble.com.

Filters attached to an appender determine whether the containing appender sees events. For example, the following configuration snipped will cause appender A to only see events of level WARN. <appender name="A" class="...."/> <filter class="ch.qos.logback.classic.filter.LevelFilter"> <level>WARN</level> <onMatch>NEUTRAL</onMatch> <onMismatch>DENY</onMismatch> </filter> </appender> Note that ch.qos.logback.classic.filter.LevelFilter is an equality filter checking on Level.WARN. Appender A will never see events of level TRACE, DEBUG, INFO and ERROR. Triggering of emails is determined by the evaluator [1] assigned to SMTPAppender. For an event to trigger a message, it must pass through all the filters attached to SMTPAppender and have the evaluator return true. HTH, [1] http://logback.qos.ch/manual/appenders.html#smtpAppender_Evaluator On 12.04.2013 16:47, romeara wrote:
Hi there,
I'm having an issue with using multiple filters as you had outlined in a previous post:
<appender name="SQL_TRANSACTION_DELAY_EMAIL" class="ch.qos.logback.classic.net.SMTPAppender"> <filter class="ch.qos.logback.classic.filter.LevelFilter"> <level>WARN</level> <onMatch>NEUTRAL</onMatch> <onMismatch>DENY</onMismatch> </filter> <filter class="com.annadaletech.taxfree.kioskapp.util.SQLTransactionDelayFilter"> <transactionDelayText>running time (millis)</transactionDelayText> </filter> ... </appender>
The first filter is looking for any log entry marked as [WARN ] and the second checks this message for my own user defined value and whether or not the email needs to be sent. However, though the second filter code is being accessed, the email is not passed from an ACCEPT filterReply.
I've also read somewhere that apparently the SMTPAppender wont send an email unless its catching an ERROR message. If so, how can I alter this?
Your thoughts appreciated,
Ray.
-- Ceki 65% of statistics are made up on the spot

Hi there, I had to scrap the filters and go with the evaluator as you had recommended: <appender name="SQL_TRANSACTION_DELAY_EMAIL" class="ch.qos.logback.classic.net.SMTPAppender"> <evaluator class="ch.qos.logback.classic.boolex.JaninoEventEvaluator"> <expression> return event.getLevel().equals(Level.WARN) && event.getMessage().contains("running time (millis)"); </expression> </evaluator> .... <layout class="ch.qos.logback.classic.PatternLayout"> <pattern>%date {%thread} [%X{id}] [%-5level] %class.%method - %message%n</pattern> </layout> </appender> Thanks again for your help. Ray. -- View this message in context: http://logback.10977.n7.nabble.com/SMTPAppender-with-multiple-filters-tp1186... Sent from the Users mailing list archive at Nabble.com.
participants (2)
-
ceki
-
romeara