[logback-user] [Sifting Appender ] Programmatically

Stuart Rossiter stuart.p.rossiter at gmail.com
Thu Apr 4 13:12:35 CEST 2013


On 28 March 2013 16:17, MychaL <mychal.13 at gmail.com> wrote:

> Because we have to create a new log dynamically and with MDC discriminator.
>

That's where I was confused. That is what the standard sifting appender
config file setup is for: dynamically creating logs based on MDC keys. So,
unless you were using some other discrimination (or something very fancy in
terms of when files were created or something), why would you
programmatically create a sifting appender? (Even in the former case, you
would still configure the sifting appender in the config file, just provide
your own discrimination class.)


>
> I made some search on AppenderFactory but dunno how to use it....
>
> We have all, except the link between SiftingAppender and FileAppender :(
>
> How is framework working to read configuration ? Is it not possible to
> have    a method to set the parent appender ?
>

The factory design pattern is pretty common in such situations (create some
context-specific class dynamically), and I assume that the framework
definitely uses it internally. You seem to be doubting that the framework
'really' works like this. (?) Unfortunately, I don't have time to look at
coding a simple factory template. Maybe someone else can help?


>
> Thank you.
>
> Le 28 mars 2013 à 14:18, Stuart Rossiter <stuart.p.rossiter at gmail.com> a
> écrit :
>
> > M. MychaL <mychal.13 at ...> writes:
>
> >>
> >> Plz, need help on this subject....Is it possible to attach the
> fileappender to
> >> the siftingappender exactly as in XML configuration ?Thank you.
> >
> > Without having done this, I presume that you need to set up an
> AppenderFactory
> > (via setAppenderFactory), since that is what will dynamically create the
> > appenders.
> >
> > It might be useful if you said why you were trying to do this though. If
> you're
> > just using MDC discrimination, why not do it in the config file?
> >
> > Stuart
>
>

> _______________________________________________
> Logback-user mailing list
> Logback-user at qos.ch
> http://mailman.qos.ch/mailman/listinfo/logback-user




-- 
________________________________
Stuart Rossiter
stuart.p.rossiter at gmail.com

Research Fellow: EPSRC Care Life Cycle Project
http://www.southampton.ac.uk/clc
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/logback-user/attachments/20130404/3978809a/attachment.html>


More information about the Logback-user mailing list