[logback-user] Enable Debugging Mode Programmatically?
Jack Vinijtrongjit
juminoz at hotmail.com
Wed Dec 14 01:19:17 CET 2011
Perfect! That works out very well.
Thanks,Jack
From: tony19 at gmail.com
Date: Tue, 13 Dec 2011 18:37:45 -0500
To: logback-user at qos.ch
Subject: Re: [logback-user] Enable Debugging Mode Programmatically?
There are a couple ways:
1) Use StatusPrinter.printInCaseOfErrorsOrWarnings(loggerContext)
OR
2) Load hard-coded string of configuration XML w/configuration.debug set to 'true':
static final String LOGBACK_XML =
"<configuration debug='true'>" + " <appender name='FILE' class='ch.qos.logback.core.RollingFileAppender'>" +
" <file>foo.log</file>" + " <append>true</append>" +
" <encoder>" + " <pattern>%-4relative [%thread] %-5level %logger{35} - %msg%n</pattern>" +
" </encoder>" + " </appender>" + " <root level='INFO'>" +
" <appender-ref ref='FILE' />" + " </root>" +
"</configuration>" ;
static public void configLogback() { LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
try { JoranConfigurator configurator = new JoranConfigurator(); configurator.setContext(lc); lc.reset();
configurator.doConfigure(new ByteArrayInputStream(LOGBACK_XML.getBytes())); } catch (JoranException je) { je.printStackTrace();
}
// you can also print the errors/warning explicitly (instead of debug='true' in xml) //StatusPrinter.printInCaseOfErrorsOrWarnings(lc);
}
On Tue, Dec 13, 2011 at 6:20 PM, Jack Vinijtrongjit <juminoz at hotmail.com> wrote:
I ended up accessing BasicStatusManager directly to get the message out so I can at least see what's going on. Then I was able to figure out that some required configuration wasn't set for RollingPolicy object.
Please let me know if there is a way to make BasicStatusManager cough up all log messages for LogBack. Otherwise, I guess I just have to do it the way I'm doing now when things are not working.
Thanks,Jack
_______________________________________________
Logback-user mailing list
Logback-user at qos.ch
http://mailman.qos.ch/mailman/listinfo/logback-user
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/logback-user/attachments/20111213/c6237d29/attachment.html>
More information about the Logback-user
mailing list