dev-rifaii
dev-rifaii

Reputation: 516

marker is not an rvalue in logback

I have this filter in my logback-spring.xml:

<filter class="ch.qos.logback.core.filter.EvaluatorFilter">
    <evaluator>
        <expression>
            return marker instanceof com.package.logging.Metrics.Marker;
        </expression>
    </evaluator>
    <onMatch>DENY</onMatch>
    <onMismatch>NEUTRAL</onMismatch>
</filter>

the filter has been working until I started upgrading my dependencies. Here's a list of the most relevant upgrades:

Now it's giving me this error on application startup:

ERROR in ch.qos.logback.classic.boolex.JaninoEventEvaluator@40d10481 - Could not start evaluator with expression [return marker instanceof com.package.logging.Metrics.Marker;] org.codehaus.commons.compiler.CompileException: Line 2, Column 8: Expression "marker" is not an rvalue

Upvotes: 3

Views: 492

Answers (1)

Spring
Spring

Reputation: 11835

Issue arises due to the deprecated getMarker() Method:

https://logback.qos.ch/apidocs/ch/qos/logback/classic/spi/ILoggingEvent.html

This is how I solved in my case:

old expression:

  <expression>return marker != null &amp;&amp; marker.getName().equals("FUNC");</expression>

changed to:

  <expression>return event.getMarkerList() != null &amp;&amp; !event.getMarkerList().isEmpty() &amp;&amp; ((org.slf4j.Marker) event.getMarkerList().get(0)).getName().equals("FUNC");</expression>

Upvotes: 3

Related Questions