<p class="MsoNormal"><b><span style lang="EN-US">How do
you create a siftingappender with a fileappender manually ?</span></b></p>
<p class="MsoNormal"><span style lang="EN-US"> </span></p>
<p class="MsoNormal"><u><span style lang="EN-US">Here my
code :</span></u></p>
<p class="MsoNormal"><span style lang="EN-US"> </span></p>
<p class="MsoNormal"><span style lang="EN-US">LoggerContext
loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();</span></p>
<p class="MsoNormal"><span style 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 style lang="EN-US"> </span></p>
<p class="MsoNormal"><span style lang="EN-US">FileAppender<ILoggingEvent>
fAppender = new FileAppender<ILoggingEvent>();</span></p>
<p class="MsoNormal"><span style lang="EN-US">fAppender.setContext(loggerContext);</span></p>
<p class="MsoNormal"><span style lang="EN-US">fAppender.setName(application
+ "_" + user);</span></p>
<p class="MsoNormal"><span style lang="EN-US">fAppender.setFile(logUser);</span></p>
<p class="MsoNormal"><span style lang="EN-US">fAppender.setAppend(true);</span></p>
<p class="MsoNormal">fAppender.setEncoder(encoder);</p>
<p class="MsoNormal"><span style lang="EN-US">fAppender.start();</span></p>
<p class="MsoNormal"><span style lang="EN-US"> </span></p>
<p class="MsoNormal"><span style lang="EN-US">MDCBasedDiscriminator
discriminator = new MDCBasedDiscriminator();</span></p>
<p class="MsoNormal"><span style lang="EN-US">discriminator.setKey("userid");</span></p>
<p class="MsoNormal"><span style lang="EN-US">discriminator.setDefaultValue("unknown");</span></p>
<p class="MsoNormal"><span style lang="EN-US">discriminator.start();</span></p>
<p class="MsoNormal"><span style lang="EN-US"> </span></p>
<p class="MsoNormal"><span style lang="EN-US">LevelFilter
lFilter = new LevelFilter();</span></p>
<p class="MsoNormal"><span style lang="EN-US">lFilter.setLevel(Level.INFO);</span></p>
<p class="MsoNormal"><span style lang="EN-US">lFilter.start();</span></p>
<p class="MsoNormal"><span style lang="EN-US"> </span></p>
<p class="MsoNormal"><span style lang="EN-US">// HOW TO
ATTACH fAppender on sAppender ????</span></p>
<p class="MsoNormal"><span style lang="EN-US">SiftingAppender
sAppender = new SiftingAppender();</span></p>
<p class="MsoNormal"><span style lang="EN-US">sAppender.setContext(loggerContext);</span></p>
<p class="MsoNormal"><span style lang="EN-US">sAppender.setName(application
+ "_" + user + "_SIFTING");</span></p>
<p class="MsoNormal"><span style lang="EN-US">sAppender.addFilter(lFilter);</span></p>
<p class="MsoNormal"><span style lang="EN-US">sAppender.setDiscriminator(discriminator);</span></p>
<p class="MsoNormal"><span style lang="EN-US">sAppender.start();</span></p>
<p class="MsoNormal"><span style lang="EN-US"> </span></p>
<p class="MsoNormal"><span style lang="EN-US">Logger
logger = loggerContext.getLogger("test.mypackage");</span></p>
<p class="MsoNormal"><span style lang="EN-US">logger.setAdditive(false);</span></p>
<p class="MsoNormal"><span style lang="EN-US">logger.setLevel(Level.ALL);</span></p>
<p class="MsoNormal"><span style lang="EN-US">logger.addAppender(sAppender);</span></p>
<p class="MsoNormal"><span style lang="EN-US"> </span></p>
<p class="MsoNormal"><span style lang="EN-US"> </span></p>
<p class="MsoNormal"><span style lang="EN-US">Thank you….</span></p>
<br><br>