Skip to content
This repository has been archived by the owner on May 27, 2022. It is now read-only.

Marker filter not working #87

Open
eddyZ opened this issue Jul 11, 2019 · 0 comments
Open

Marker filter not working #87

eddyZ opened this issue Jul 11, 2019 · 0 comments

Comments

@eddyZ
Copy link

eddyZ commented Jul 11, 2019

Hi,

I have two different appenders that filter based on markers.
Both should only append logs with my 'AUDIT' marker. Although if the filter is exactly the same in both appenders, it works for the console appender, but not for the Kafka appender. In Kafka, no messages appear (but if I remove the filter, they show up).

<appender name="fast-kafka-appender" class="com.github.danielwegener.logback.kafka.KafkaAppender">
    <filter class="ch.qos.logback.core.filter.EvaluatorFilter">
        <evaluator class="ch.qos.logback.classic.boolex.OnMarkerEvaluator">
            <marker>AUDIT</marker>
        </evaluator>
        <onMismatch>DENY</onMismatch>
        <onMatch>NEUTRAL</onMatch>
    </filter>

    <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
        <pattern>AUDITING: %d{HH:mm:ss.SSS} [%thread] %-5level %marker %logger{36} - %msg%n</pattern>
    </encoder>

    <topic>audit-logs</topic>
    <keyingStrategy class="com.github.danielwegener.logback.kafka.keying.NoKeyKeyingStrategy" />
    <deliveryStrategy class="com.github.danielwegener.logback.kafka.delivery.AsynchronousDeliveryStrategy" />

    <producerConfig>bootstrap.servers=localhost:9092</producerConfig>
    <producerConfig>acks=0</producerConfig>
    <producerConfig>linger.ms=100</producerConfig>
    <producerConfig>max.block.ms=2</producerConfig>
    <producerConfig>client.id=${HOSTNAME}-${CONTEXT_NAME}-logback-relaxed</producerConfig>

</appender>
<appender name="AUDIT_LOG" class="ch.qos.logback.core.ConsoleAppender">
    <!-- the filter element -->
    <filter class="ch.qos.logback.core.filter.EvaluatorFilter">
        <evaluator class="ch.qos.logback.classic.boolex.OnMarkerEvaluator">
            <marker>AUDIT</marker>
        </evaluator>
        <onMismatch>DENY</onMismatch>
        <onMatch>NEUTRAL</onMatch>
    </filter>
    <encoder>
        <pattern>
            %green(eddas log: %d{ISO8601}) %highlight(%-5level) [%blue(%t)] %yellow(%logger{36}): %magenta(%msg%n%throwable)
        </pattern>
    </encoder>
</appender>

I managed also to exclude all my AUDIT logs like that:
<filter class="ch.qos.logback.core.filter.EvaluatorFilter"> <evaluator class="ch.qos.logback.classic.boolex.OnMarkerEvaluator"> <marker>AUDIT</marker> </evaluator> <onMatch>DENY</onMatch> </filter>
This works, but it is the opposite of what I need ;)

Can you tell my why my filter is not working?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant