I use SiftingAppender
and RollingFileAppender
to separate log folders with a discriminator key.
<appender name="TEST_LOGGER" class="ch.qos.logback.classic.sift.SiftingAppender">
<discriminator>
<key>discKey</key>
<defaultValue>Default</defaultValue>
</discriminator>
<sift>
...
</sift>
</appender>
But I just need the discriminator keys that set and don't need a folder with name of defaultValue
. is there any way to just separate needed folders and remove others?
After a lot of searching in Logback
docs, I found that by using the filtering
method, it is possible to register the required values and not register the other values.
<appender name="TEST_LOGGER" class="ch.qos.logback.classic.sift.SiftingAppender">
<discriminator>
<key>discKey</key>
<defaultValue>Default</defaultValue>
</discriminator>
<filter class="ch.qos.logback.core.filter.EvaluatorFilter">
<evaluator class="ch.qos.logback.classic.boolex.JaninoEventEvaluator">
<expression>
mdc.get("discKey") == null
</expression>
</evaluator>
<OnMismatch>NEUTRAL</OnMismatch>
<OnMatch>DENY</OnMatch>
</filter>
<sift>
...
</sift>
</appender>
Above code do not register Default
folder.