I made a new method that had the same setup but passed the doConfigure() method the path and name of the xml file i wanted parsed. Also uncomment the context.reset() and run both methods.
joranConfigurator doing multiple tasks
Question
I have a project where logback uses joranConfigurator to get a system variable in a startup bean, but I also want to tell it to parse an XML file with the logback configuration AFTER it has already gotten the variable set up... I cant rely on using the standard logback.xml name because the way the project is set up I have to do it this way
heres my current code:
private void configureLogBack() {
LoggerContext context = (LoggerContext)LoggerFactory.getILoggerFactory();
try {
JoranConfigurator configurator = new JoranConfigurator();
configurator.setContext(context);
// Call context.reset() to clear any previous configuration, e.g.
// default
// configuration. For multi-step configuration, omit calling
// context.reset().
// context.reset();
configurator.doConfigure(System.getenv("logPath"));
} catch (JoranException je) {
// StatusPrinter will handle this
}
StatusPrinter.printInCaseOfErrorsOrWarnings(context);
}
do I do context.reset()
then do another configurator.doConfigure()
? and what do I pass in as the argument, the name of the xml file???
thank you!
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow