
On 11 April 2013 15:53, diroussel <nabble@diroussel.xsmail.com> wrote:
Stuart,
I understand what you mean now. It definately creates the dynamic appender on append. I've been reading the source that does that, SiftingAppenderBase, today looking at another issue.
I can see why it wouldn't make sense to ido it in MDC.put(). Maybe there is another way?
I take if your encoder is dynamic, so can't be specified in logback.xml.
- Maybe you can do it with a logback.groovy file, I've heard that is more flexible.
- Maybe you could define many appenders, one for each encoder, and then use a filter to control which one the event goes to?
- Maybe you could use a variable name in the encoder class name, which is replaced by the sifter before the appender is created? Annoyingly SiftingApender only works on one key at a time, so this might not work for you.
David
It would be less annoying if the addition occurred before active logging levels were checked, because then I could log a dummy TRACE level message to get things started. Unfortunately, I have to log something that actually gets logged, so have to use ERROR level to be safe. I don't think your last two possibilities will fly in my case, because my encoder has run-time 'things' in it (so it can't be instantiated via any kind of default constructor). Anyway, I have a simple-ish workaround, and may investigate more (incl. looking at the Logback source) when/if I have time. Thanks, Stuart