This document was generated from CDN thread
Created by: Binny Mathew on 29-08-2012 01:47:38 AM
I am working with logback.xml and below is the snippet that i am using so as every call will have a log based on the icm-call-id.
Initially when the Application loads the icm-call-id will not be there so the an "unknown.log" gets created (defaultValue).
<!--Working fine -->
<appender name="SIFT" class="ch.qos.logback.classic.sift.SiftingAppender">
<discriminator>
<key>icm_call_id</key>
<defaultValue>unkown</defaultValue>
</discriminator>
<sift>
<appender name="FILE-${icm_call_id}" class="ch.qos.logback.core.FileAppender">
<file>c:/tmp/DWHConfig/logs/hu/${icm_call_id}.log</file>
<append>false</append>
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>%d [%thread] %level %mdc %logger{35} - %msg%n</pattern>
</layout>
</appender>
</sift>
</appender>
The issue is whenever i try to implement the filter parameter the log (nor the icm-call-id or the unknown.log) gets written
<filter class="ch.qos.logback.core.filter.EvaluatorFilter">
<!-- GEventEvaluator requires Groovy -->
<evaluator class="ch.qos.logback.classic.boolex.GEventEvaluator">
<expression>
(mdc.get("icm_call_id") == null)
</expression>
</evaluator>
<OnMismatch>NEUTRAL</OnMismatch>
<OnMatch>DENY</OnMatch>
</filter>
What am i missing here?? When i try to implement the timeBasedPolicy only on the unknown.log that too does not work.
Binny
Subject: RE: logback.xml SIFT Appenders
Replied by: Binny Mathew on 06-09-2012 08:31:43 AM
The issue was resolved.
I wrote a custom class for the filter which would decide to write the log or not. Below is the snippet
<appender name="SIFT" class="ch.qos.logback.classic.sift.SiftingAppender">
<discriminator>
<key>icm_call_id</key>
<defaultValue>unkown</defaultValue>
</discriminator>
<sift>
<appender name="FILE-${icm_call_id}" class="ch.qos.logback.core.FileAppender">
<filter class="com.citi.global.util.LogbackFilter"/>
<file>c:/tmp/DWHConfig/logs/hu/${icm_call_id}.log</file>
<append>false</append>
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>%d [%thread] %level %mdc %logger{35} - %msg%n</pattern>
</layout>
</appender>
</sift>
</appender>
Thanks
Binny