[logback-user] Split logs to different files by MDC?

Yura Levandovskyy liova_89 at yahoo.ca
Fri Jun 15 20:26:43 CEST 2012


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 at qos.ch>
To: logback users list <logback-user at 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

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,
_______________________________________________
Logback-user mailing list
Logback-user at qos.ch
http://mailman.qos.ch/mailman/listinfo/logback-user
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/logback-user/attachments/20120615/b767f84b/attachment.html>


More information about the Logback-user mailing list