<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">I realized I needed to move my
ServletContextListener above the Spring ContextLoaderListener in
my web.xml. However it is still creating a
application-name_IS_UNDEFINED.log, though an empty (0 byte) one.<br>
<br>
Putting a breakpoint on the ContextLoaderListener<b> </b>doConfigure
methods, I see it is getting called as a result of the line <br>
<br>
LoggerContext context = (LoggerContext)
LoggerFactory.getILoggerFactory(); <br>
<br>
(from the manual's example) via org.slf4j.impl.StaticLoggerBinder
init method (from the logback-classic.jar).<br>
<br>
Any suggestions how I can avoid that? Is there a better way to get
the LoggerContext?<br>
<br>
Eric<br>
<br>
On 8/22/2012 2:53 PM, Eric Schwarzenbach wrote:<br>
</div>
<blockquote cite="mid:50352A98.9070105@blackbrook.org" type="cite">I'm
trying to use variable substitution for my log file names, using
the webapp / context name. (My use case is not literally a shared
configuration, but two webapps deployed using copies of the same
war with different names...so they each have their own
logback.xml, though they are identical). I'm using the example on
<a class="moz-txt-link-freetext" href="http://logback.qos.ch/faq.html#sharedConfiguration">http://logback.qos.ch/faq.html#sharedConfiguration</a> as my basis,
and while it is working, my webapp ends up creating two log files.
<br>
<br>
First it creates one called application-name_IS_UNDEFINED.log with
some of the first messages logged during startup, and then foo.log
(where foo is the app name) with all subsequent messages. So it
seems to me that the contextInitialized method of
ServletContextListener isn't early enough, and that the default
logback config is initializing earlier. This is using Tomcat 7,
and Java 7.
<br>
<br>
How can I either hook into the earlier initialization or replace
it? Where does that initialization happen? Is that static code?
<br>
<br>
Thanks,
<br>
<br>
Eric
<br>
<br>
_______________________________________________
<br>
Logback-user mailing list
<br>
<a class="moz-txt-link-abbreviated" href="mailto:Logback-user@qos.ch">Logback-user@qos.ch</a>
<br>
<a class="moz-txt-link-freetext" href="http://mailman.qos.ch/mailman/listinfo/logback-user">http://mailman.qos.ch/mailman/listinfo/logback-user</a>
<br>
<br>
</blockquote>
<br>
</body>
</html>