[prev in list] [next in list] [prev in thread] [next in thread]
List: logback-user
Subject: Re: [logback-user] Split logs to different files by MDC?
From: Yura Levandovskyy <liova_89 () yahoo ! ca>
Date: 2012-06-15 20:22:24
Message-ID: 1339791744.25621.YahooMailNeo () web162705 ! mail ! bf1 ! yahoo ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
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.
________________________________
From: ceki <ceki@qos.ch>
To: logback users list <logback-user@qos.ch>
Sent: Friday, June 15, 2012 3:59:51 PM
Subject: Re: [logback-user] Split logs to different files by MDC?
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,
_______________________________________________
Logback-user mailing list
Logback-user@qos.ch
http://mailman.qos.ch/mailman/listinfo/logback-user
[Attachment #5 (text/html)]
<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>
_______________________________________________
Logback-user mailing list
Logback-user@qos.ch
http://mailman.qos.ch/mailman/listinfo/logback-user
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic