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