<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt"><div><span><span>This is the appender in question:</span><br></span></div><div><span><br></span></div><div><span><appender name="SIFT" class="ch.qos.logback.classic.sift.SiftingAppender"><br> <discriminator><br> <key>variable</key><br> <defaultValue>default</defaultValue><br> </discriminator><br> <sift><br> <appender name="FILE-${variable}" class="ch.qos.logback.core.FileAppender"><br>
<file>${home}/logs/${variable}.log</file> <br> <append>false</append><br> <layout class="ch.qos.logback.classic.PatternLayout"><br> <pattern>[%X{variable}]</pattern><br> </layout><br> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <br> <fileNamePattern>${home}/logs/${variable}.%d{yyyy-MM-dd}.%d{HHmm,aux}.%i.log</fileNamePattern> <br>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATPExt"><br> <maxFileSize>50KB</maxFileSize><br> </timeBasedFileNamingAndTriggeringPolicy><br> <maxHistory>30</maxHistory><br> </rollingPolicy><br> </appender><br> </sift><br></appender></span></div><div><br><span></span></div><div><span></span></div><div><br></div> <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> Wednesday, June 13, 2012 5:49:31 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 can contain any other appenders except another <br>SiftingAppender. Can you post your config file?<br><br>On 13.06.2012 23:47, Yura Levandovskyy wrote:<br>> Great, SiftingAppender seems to be what I need, once I can configure it<br>> correctly<br>><br>> Could you assist with rolling policy for
it? I have a rolling policy<br>> that rolls over on size. Whether I put it in the sifting appender<br>> (*<appendername="SIFT"class="ch.qos.logback.classic.sift.SiftingAppender">)<br>> *<br>> or one of the generated ones*<br>> *<br>> *(**<appendername="FILE-${userid}"class="ch.qos.logback.core.FileAppender">)*<br>> it seems to have no effect in either case. The rolling policy works fine<br>> in a separate FileAppender. Is it possible to add a rolling policy for a<br>> sifting appender, am I missing something?<br>><br>> Thank you.<br>><br>><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:* Tuesday, June 12, 2012
4:00:28 PM<br>> *Subject:* Re: [logback-user] Split logs to different files by MDC?<br>><br>><br>> I'd suggest to re-write the expression as<br>><br>> ((String))mdc.get("variable").matches("/test/")<br>><br>> Are you familiar with SiftingAppender? It seems to address a use case<br>> similar to yours.<br>> HTH,<br>><br>> [1] <a href="http://logback.qos.ch/manual/appenders.html#SiftingAppender" target="_blank">http://logback.qos.ch/manual/appenders.html#SiftingAppender</a><br>><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>><br>> On 12.06.2012 20:17, Yura Levandovskyy wrote:<br>> > Hello<br>> ><br>> > I have an application that has an mdc variable. How can I make a proper<br>> > filter,
so that if variable = test, all such output goes to one file,<br>> > and to another file if variable is anything else?<br>> ><br>> > I tried the following (not sure how to go from there even if it worked<br>> > though):<br>> ><br>> > <expression><br>> > mdc?.get("variable") ~= /test/<br>> > </expression><br>> ><br>> > but the result is<br>> ><br>> > ERROR in ch.qos.logback.classic.boolex.JaninoEventEvaluator@7d55b9f -<br>> > Could not start evaluator with expression [mdc?.get("variable") ~=<br>> /test/ )]<br>> ><br>> > Any suggestions?<br>> ><br>> > Thanks<br>> ><br><br><br>-- <br>Ceki<br><a href="http://twitter.com/#%21/ceki"
target="_blank">http://twitter.com/#!/ceki</a><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>