[logback-user] Question about MDC in servlet init() method

Stefan Frings stefan at meinemullemaus.de
Sat Mar 1 23:53:58 CET 2008

Question was:

> Can I set MDC variables in init() and read them in service() safely,
> or does this work only randomly or under special conditions?

I found the answer myself, because I managed to reproduce the
problem :-)

Obviously, MDC variables get lost when the application is idle for a
while. So I am sure now that I have to set them again in the first
lines of service() before I can read them. In service() I cannot
safely use MDC variables that have been set in init().

Is that correct?

More information about the Logback-user mailing list