[logback-dev] [JIRA] Commented: (LBCORE-118) EvaluatorFilter returns OnMatch when marker is null

Ceki Gulcu (JIRA) noreply-jira at qos.ch
Tue Nov 10 21:12:44 CET 2009

    [ http://jira.qos.ch/browse/LBCORE-118?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=11367#action_11367 ] 

Ceki Gulcu commented on LBCORE-118:

When the marker is null, during the evaluation of the boolean expression a NullPointerException is thrown. This exception is added into the internal list of status messages. Moreover, since the result of the evaluation is undetermined (an exception was thrown), neither OnMatch nor OnMismatch properties apply and  the EvaluatorFilter returns NEUTRAL, as it should.

One way to fix this issue, is to modify the evaluator expression to "marker != null &&  marker.getName().equals("Alert")". 

I am hesitating to modify JaninoEventEvaluator to inject a dummy marker in case the logging event's marker is null. This would solve the issue you are facing. 

> EvaluatorFilter returns OnMatch when marker is null
> ---------------------------------------------------
>                 Key: LBCORE-118
>                 URL: http://jira.qos.ch/browse/LBCORE-118
>             Project: logback-core
>          Issue Type: Bug
>          Components: Other
>    Affects Versions: 0.9.17
>         Environment: Windows XP
>            Reporter: Manuel Kueblboeck
>            Assignee: Ceki Gulcu
>            Priority: Minor
> <appender name="Alert" class="ch.qos.logback.core.ConsoleAppender">
>     <filter class="ch.qos.logback.core.filter.EvaluatorFilter">
>       <evaluator name="isAlert">
>         <expression>marker.getName().equals("Alert")</expression>
>       </evaluator>
>       <OnMatch>ACCEPT</OnMatch>
>       <OnMismatch>DENY</OnMismatch>
>     </filter>
>     <layout class="ch.qos.logback.classic.PatternLayout">
>       <Pattern>ALERT: %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</Pattern>
>     </layout>
> </appender>
> In the above example, when an event is logged without an attached marker, the filter returns OnMatch. I would expect that it returns OnMismatch.
> A work around for this issue is to change the expression to this:
> <expression>marker != null &amp;&amp; marker.getName().equals("Alert")</expression>

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators: http://jira.qos.ch/secure/Administrators.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the logback-dev mailing list