<div dir="ltr">On 11 April 2013 14:34, diroussel <span dir="ltr"><<a href="mailto:nabble@diroussel.xsmail.com" target="_blank">nabble@diroussel.xsmail.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I'm using logback 1.0.9 and this works for me.<br>
<br>
When I set an MDC key, then the very next log statement will cause it to go<br>
to a new appender and new log file.<br></blockquote><div><br></div><div style>Yes, this does happen for me as well. What I mean is that Logback only adds the appender dynamically *within the log statement method*, rather than as soon as the MDC key is set.</div>
<div style><br></div><div style>This is a problem for me because I want to amend the dynamically created appender (replacing the encoder with my own) *before* logging anything. As in my original msg, the wording in the manual strongly suggests that the appender is created at MDC put-time, and so is misleading. It would also seem more 'correct' to support use cases like mine.</div>
<div style><br></div><div style>(There's also a secondary issue: currently one *must* specify an encoder in the config file for the dynamically created sub-appender. It would be better if one could omit the encoder when one knew that one was adding one's own, avoiding the unnecessary initialisation. It perhaps also fits better conceptually: an appender will just do nothing until an encoder is added, rather than requiring the full 'stack' of appender-->encoder-->layout before being able to start.)</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
What do you mean that you need to send a spurious message first?<br></blockquote><div><br></div><div style>I log a message to actually trigger the sub-appender addition. (I don't want to do this since it is using an encoder which I don't want to use.) Hope that makes it clearer!</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
David<br><br></blockquote><div style><br></div><div style>Many thanks for the response anyway. <br></div></div><br><div><br></div><div><br></div>
</div></div>