[logback-user] Why are encoder-less appenders not consistently allowed?

Stuart Rossiter stuart.p.rossiter at gmail.com
Thu Mar 28 13:56:41 CET 2013


I have a need to dynamically adjust appenders at run-time to use a custom
Layout. What I really want is to have encoder-less appenders set up (via
the config file) and then add the appropriate LayoutWrappingEncoder
programmatically. This works fine for a basic FileAppender. *However*, this
fails for a ConsoleAppender, or (interestingly) for a FileAppender created
dynamically by a SiftingAppender. (You get errors that an encoder has to be
set and that the init method can't be invoked.)

Is there a reason for this inconsistency? I suspect it might just be that
there is inconsistent handling internally of when an appender is
started(??). (I assume the init method that is being referred to in the
error messages is start().)

(The context is that this is logging from a simulation. I want all log
messages to be prefixed with the simulation time, which is something that
is only available within the application, and differs per logged message. I
guess I could use a SimTime MDC key which is updated before each message
logged, but that's a bit clumsy. Doing it generically inside a Layout,
independent of the rest of the simulation code, is much better.)

Stuart

-- 
________________________________
Stuart Rossiter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/logback-user/attachments/20130328/bdd335c5/attachment.html>


More information about the Logback-user mailing list