
SiftingAppender replays elements found within <sift>...</sift> when it creates a new appender instance. You probably do not want SiftingAppender to do conditional configuration each time it creates a new appender. As such, I would remommend to move the conditional part outside the <sift></sift> element. Is that possible? -- Ceki http://twitter.com/#!/ceki On 15.06.2012 20:26, Yura Levandovskyy wrote:
Oh wow, I actually haven't noticed that I just have FileAppender, not RollingFileAppender The 'home' property is defined higher up, so that part works well now Thank you for the hint about debug, going to save a lot of frustration
Could you advise on how to use <if> with mdc values? What I'm trying is the following:
I have this in my SiftingAppender: <discriminator> <key>variable</key> <defaultValue>default</defaultValue> </discriminator>
I want to determine the file name depending on the property, such that (inside rollingPolicy):
<if condition='property("variable").equals("default")'> <then> <fileNamePattern>${home}/logs/generic-logs.%d{yyyy-MM}.%i.log</fileNamePattern>
</then> <else> <fileNamePattern>${home}/logs/${variable}.%d{yyyy-MM-dd}.%d{HHmm,aux}.%i.log</fileNamePattern> </else> </if>
At the moment the .equals check seems to fail all the time, and so the 1st fileNamePattern is never used. What am I doing wrong?
------------------------------------------------------------------------ *From:* ceki <ceki@qos.ch> *To:* logback users list <logback-user@qos.ch> *Sent:* Thursday, June 14, 2012 1:02:19 PM *Subject:* Re: [logback-user] Split logs to different files by MDC?
By the way, since the home property is used within SiftingAppender, it should be defined in the "context" scope. Example:
<property name="home" value="/tmp" scope="context"/>
HTH, -- Ceki http://twitter.com/#!/ceki <http://twitter.com/#%21/ceki>
On 14.06.2012 18:57, ceki wrote:
Hi Yura,
There multiple errors in the config you provided (independent of SiftingAppender). As a general recommendation, you should set the debug attribute to true to see the errors.
<configuration debug="true"> ... </configuration?
Here are a few hints.
Hint1: ch.qos.logback.core.rolling.RollingFileAppender not FileAppender Hint2: SizeAndTimeBasedFNATPExt does not exist
HTH,