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