[logback-user] Setting log filename during runtime
Jenny
jenny_uy81 at yahoo.com
Fri Nov 7 20:58:03 CET 2008
Hello,
How can i set the log filename set during the init() of my StartupServlet.
I tried using MDC but it's not working for me.
What happens is the file is not created. Instead a file with name "%exp{logFileName}" is created on my web server's bin directory.
In my StartupServlet, I have this init method that calls MDC.put().
public void init() throws ServletException {
MDC.put("logFileName", "c:\\testlogs\\test.log");
Logger log = LoggerFactory.getLogger(StartupServlet.class);
log.info("This should be logged");
}
In my logback.xml, I have a MDC.get().
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<append>true</append>
<expression name="logFileName">MDC.get("logFileName")</expression>
<file>%exp{logFileName}</file>
...
I'm new with logback, thanks in advance for your help! I'm trying to follow Ceki's example in his blog
http://ceki.blogspot.com/2006/10/repated-configuration-with-joran.html
thanks,
jenny
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://qos.ch/pipermail/logback-user/attachments/20081107/4293c8e7/attachment.htm
More information about the Logback-user
mailing list