Plz, need help on this subject....<br><br>Is it possible to attach the fileappender to the siftingappender exactly as in XML configuration ?<br><br>Thank you.<br><br><div class="gmail_quote">2013/2/14 M. MychaL <span dir="ltr"><<a href="mailto:mychal.13@gmail.com" target="_blank">mychal.13@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<p class="MsoNormal"><b><span lang="EN-US">How do
you create a siftingappender with a fileappender manually ?</span></b></p>
<p class="MsoNormal"><span lang="EN-US"> </span></p>
<p class="MsoNormal"><u><span lang="EN-US">Here my
code :</span></u></p>
<p class="MsoNormal"><span lang="EN-US"> </span></p>
<p class="MsoNormal"><span lang="EN-US">LoggerContext
loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();</span></p>
<p class="MsoNormal"><span lang="EN-US"> </span></p>
<p class="MsoNormal">PatternLayoutEncoder encoder = new PatternLayoutEncoder();</p>
<p class="MsoNormal">encoder.setContext(loggerContext);</p>
<p class="MsoNormal">encoder.setPattern("<%d(yyyy-MM-dd
HH:mm:ss=> | %.-1level | %msg %n");</p>
<p class="MsoNormal">encoder.start();</p>
<p class="MsoNormal"><span lang="EN-US"> </span></p>
<p class="MsoNormal"><span lang="EN-US">FileAppender<ILoggingEvent>
fAppender = new FileAppender<ILoggingEvent>();</span></p>
<p class="MsoNormal"><span lang="EN-US">fAppender.setContext(loggerContext);</span></p>
<p class="MsoNormal"><span lang="EN-US">fAppender.setName(application
+ "_" + user);</span></p>
<p class="MsoNormal"><span lang="EN-US">fAppender.setFile(logUser);</span></p>
<p class="MsoNormal"><span lang="EN-US">fAppender.setAppend(true);</span></p>
<p class="MsoNormal">fAppender.setEncoder(encoder);</p>
<p class="MsoNormal"><span lang="EN-US">fAppender.start();</span></p>
<p class="MsoNormal"><span lang="EN-US"> </span></p>
<p class="MsoNormal"><span lang="EN-US">MDCBasedDiscriminator
discriminator = new MDCBasedDiscriminator();</span></p>
<p class="MsoNormal"><span lang="EN-US">discriminator.setKey("userid");</span></p>
<p class="MsoNormal"><span lang="EN-US">discriminator.setDefaultValue("unknown");</span></p>
<p class="MsoNormal"><span lang="EN-US">discriminator.start();</span></p>
<p class="MsoNormal"><span lang="EN-US"> </span></p>
<p class="MsoNormal"><span lang="EN-US">LevelFilter
lFilter = new LevelFilter();</span></p>
<p class="MsoNormal"><span lang="EN-US">lFilter.setLevel(Level.INFO);</span></p>
<p class="MsoNormal"><span lang="EN-US">lFilter.start();</span></p>
<p class="MsoNormal"><span lang="EN-US"> </span></p>
<p class="MsoNormal"><span lang="EN-US">// HOW TO
ATTACH fAppender on sAppender ????</span></p>
<p class="MsoNormal"><span lang="EN-US">SiftingAppender
sAppender = new SiftingAppender();</span></p>
<p class="MsoNormal"><span lang="EN-US">sAppender.setContext(loggerContext);</span></p>
<p class="MsoNormal"><span lang="EN-US">sAppender.setName(application
+ "_" + user + "_SIFTING");</span></p>
<p class="MsoNormal"><span lang="EN-US">sAppender.addFilter(lFilter);</span></p>
<p class="MsoNormal"><span lang="EN-US">sAppender.setDiscriminator(discriminator);</span></p>
<p class="MsoNormal"><span lang="EN-US">sAppender.start();</span></p>
<p class="MsoNormal"><span lang="EN-US"> </span></p>
<p class="MsoNormal"><span lang="EN-US">Logger
logger = loggerContext.getLogger("test.mypackage");</span></p>
<p class="MsoNormal"><span lang="EN-US">logger.setAdditive(false);</span></p>
<p class="MsoNormal"><span lang="EN-US">logger.setLevel(Level.ALL);</span></p>
<p class="MsoNormal"><span lang="EN-US">logger.addAppender(sAppender);</span></p>
<p class="MsoNormal"><span lang="EN-US"> </span></p>
<p class="MsoNormal"><span lang="EN-US"> </span></p>
<p class="MsoNormal"><span lang="EN-US">Thank you….</span></p>
<br><br>
</blockquote></div><br>