Evaluators and Markers - no applicable action

I am trying to setup a simple evaluator for an appender. I want certain debug messages to be emailed, while the default will just go to stdout. Here is my context (note for this test both appenders output to the console, although one is named EMAIL): <configuration> <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> <encoder> <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern> </encoder> </appender> <appender name="EMAIL" class="ch.qos.logback.core.ConsoleAppender"> <evaluator class="ch.qos.logback.classic.boolex.OnMarkerEvaluator"> <marker>NOTIFY_ADMIN</marker> </evaluator> <encoder> <pattern>%d{HH:mm:ss.SSS} %-5level %logger{36} - %msg%n</pattern> </encoder> </appender> <root> <level value="debug" /> <appender-ref ref="STDOUT" /> <appender-ref ref="EMAIL" /> </root> </configuration> The context gives the following error: 07:30:14,121 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@19:72 - no applicable action for [evaluator], current pattern is [[configuration][appender][evaluator]] 07:30:14,121 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@20:15 - no applicable action for [marker], current pattern is [[configuration][appender][evaluator][marker]] Any ideas? Also, can you describe the difference between and evaluator and a filter? ----- Buzzterrier http://buzzterrier.blogspot.com/ View my blog: Ordinary Average Developer... -- View this message in context: http://old.nabble.com/Evaluators-and-Markers----no-applicable-action-tp28609... Sent from the Logback User mailing list archive at Nabble.com.

Hello "Buzzterrier", You probably meant to set the class name for the EMAIL appender to SMTPAppender but since you used ConsoleAppender instead, joran is incapable for injecting an evaluator into ConsoleAppender because ConsoleAppender does not support evaluators. Joran should have complained about not being able to inject the evaluator. If it has not, it's a bug. Changing the class of the appender named EMAIL from ConsoleAppender to SMTPAppender should fix the problem. As for your question on the difference between filters and evaluators, filters are supported by all appenders and are used to determine whether to drop an logging event or not. An appender can have zero or more filters. On the other hand, evaluators are used to check whether a special event has occurred. In the case of SMTPAppender, evaluators are used to trigger an outgoing email. SMTPAppender requires one and only one evaluator. If you do not supply one, it defaults to on OnErrorEvaluator. BTW, you can add filters SMTPAppender to drop certain events from entering SMTPAppender internal events. However, it it still SMTPAppender's evaluator which will determine when to trigger an email. HTH, On 19/05/2010 7:20 PM, buzzterrier wrote:
I am trying to setup a simple evaluator for an appender. I want certain debug messages to be emailed, while the default will just go to stdout.
Here is my context (note for this test both appenders output to the console, although one is named EMAIL):
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> <encoder> <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern> </encoder> </appender>
<appender name="EMAIL" class="ch.qos.logback.core.ConsoleAppender">
<evaluator class="ch.qos.logback.classic.boolex.OnMarkerEvaluator"> <marker>NOTIFY_ADMIN</marker> </evaluator>
<encoder> <pattern>%d{HH:mm:ss.SSS} %-5level %logger{36} - %msg%n</pattern> </encoder>
</appender>
<root> <level value="debug" /> <appender-ref ref="STDOUT" /> <appender-ref ref="EMAIL" /> </root> </configuration>
The context gives the following error: 07:30:14,121 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@19:72 - no applicable action for [evaluator], current pattern is [[configuration][appender][evaluator]] 07:30:14,121 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@20:15 - no applicable action for [marker], current pattern is [[configuration][appender][evaluator][marker]]
Any ideas?
Also, can you describe the difference between and evaluator and a filter?
----- Buzzterrier
http://buzzterrier.blogspot.com/ View my blog: Ordinary Average Developer...

Thank you Ceki. I was using the consoleAppender as a test, so that is what bit me. Is there any reason why evaluators are not supported in other appenders? I could see this as also being valuable for DBAppender and JMSAppenders. Ceki Gulcu wrote:
Hello "Buzzterrier",
You probably meant to set the class name for the EMAIL appender to SMTPAppender but since you used ConsoleAppender instead, joran is incapable for injecting an evaluator into ConsoleAppender because ConsoleAppender does not support evaluators. Joran should have complained about not being able to inject the evaluator. If it has not, it's a bug.
Changing the class of the appender named EMAIL from ConsoleAppender to SMTPAppender should fix the problem.
As for your question on the difference between filters and evaluators, filters are supported by all appenders and are used to determine whether to drop an logging event or not. An appender can have zero or more filters.
On the other hand, evaluators are used to check whether a special event has occurred. In the case of SMTPAppender, evaluators are used to trigger an outgoing email. SMTPAppender requires one and only one evaluator. If you do not supply one, it defaults to on OnErrorEvaluator.
BTW, you can add filters SMTPAppender to drop certain events from entering SMTPAppender internal events. However, it it still SMTPAppender's evaluator which will determine when to trigger an email.
HTH,
_ Logback-user mailing list Logback-user@qos.ch http://qos.ch/mailman/listinfo/logback-user
----- Buzzterrier http://buzzterrier.blogspot.com/ View my blog: Ordinary Average Developer... -- View this message in context: http://old.nabble.com/Evaluators-and-Markers----no-applicable-action-tp28609... Sent from the Logback User mailing list archive at Nabble.com.

On 19/05/2010 9:55 PM, buzzterrier wrote:
I was using the consoleAppender as a test, so that is what bit me. Is there any reason why evaluators are not supported in other appenders? I could see this as also being valuable for DBAppender and JMSAppenders.
EvaluatorFilter (see [1]) acts as a filter by encapsulating any evaluator. So it is possible to have any evaluator act as a filter. HTH, -- Ceki [1] http://logback.qos.ch/manual/filters.html#evalutatorFilter

Thx. Ceki, that works, but I have a question about how the filtering works: Java Main: public static void main(String[] args) { Marker notifyAdminMarker = MarkerFactory.getMarker("NOTIFY_ADMIN"); Logger logger = LoggerFactory.getLogger(LogBackTest.class); logger.debug("This is a regular debug message"); logger.debug(notifyAdminMarker, "Serious issue"); } } Logback.xml snippet: <appender name="EMAIL" class="ch.qos.logback.core.ConsoleAppender"> <filter class="ch.qos.logback.core.filter.EvaluatorFilter"> <evaluator> <expression>marker.contains("NOTIFY_ADMIN")</expression> </evaluator> <OnMatch>ACCEPT</OnMatch> <OnMismatch>DENY</OnMismatch> </filter> <encoder> <pattern>%d{HH:mm:ss.SSS} %-5level %logger{36} - %msg%n</pattern> </encoder> </appender> Running the above java and appender I get: 08:10:39.183 DEBUG aero.blue.logtest.LogBackTest - This is a regular debug message 08:10:39.190 DEBUG aero.blue.logtest.LogBackTest - Serious issue I expected to just get the Serious Issue line. Further, if I change the eval logic to Not match i.e.: <expression>!marker.contains("NOTIFY_ADMIN")</expression> I get: 08:16:47.035 DEBUG aero.blue.logtest.LogBackTest - This is a regular debug message Which is what I would expect, so is the inverse not working? ----- Buzzterrier http://buzzterrier.blogspot.com/ View my blog: Ordinary Average Developer... -- View this message in context: http://old.nabble.com/Evaluators-and-Markers----no-applicable-action-tp28609... Sent from the Logback User mailing list archive at Nabble.com.
participants (2)
-
buzzterrier
-
Ceki Gülcü