[logback-user] context-name in WebApplicationInitializer

Robert . robert.discussions at gmail.com
Mon Oct 31 10:24:39 UTC 2016


I'm trying to set the context-name for each web application to try to
separate logging per web application as documented in
http://logback.qos.ch/manual/loggingSeparation.html

I am using a WebApplicationInitializer so try to set the
logback/context-name env-entry in Java code. I have tried the following in
the onStartup method:

InitialContext initialContext = new InitialContext();
initialContext.addToEnvironment("logback/context-name", "mycontext");

I see logback is trying to get the contextName in
ContextJNDISelector.getLoggerContext().
Unfortunately the lookup returns null even though I can see the
"logback/context-name" entry in ctx.getEnvironment()

What's the correct way to add the context-name to IntialContext?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/logback-user/attachments/20161031/ee0e91cd/attachment.html>


More information about the logback-user mailing list