Hello, I didn't know this project. After checking, I dislike the way it intercept (ie print but not write).
I already write an interception code (on write) and it is working without limitation.
However I have to use reflection and reload logback (+- 200ms), the method I ask is just a way to improve performance and maintenance.
Field streamField = ConsoleTarget.class.getDeclaredField("stream");
streamField.setAccessible(true);
streamField.set(ConsoleTarget.SystemOut, System.out);
streamField.set(ConsoleTarget.SystemErr, System.err);
streamField.setAccessible(false);
LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
ContextInitializer ci = new ContextInitializer(loggerContext);
URL url = ci.findURLOfDefaultConfigurationFile(true);
try {
JoranConfigurator configurator = new JoranConfigurator();
configurator.setContext(loggerContext);
loggerContext.reset();
configurator.doConfigure(url);
} catch (JoranException je) {
// StatusPrinter will handle this }
StatusPrinter.printInCaseOfErrorsOrWarnings(loggerContext);
I think about another clean solution if logback provides a way to install a hook just after slf4j call, so I can set a thread local.
I also think about checking the stack and looking for a subclass of slf4j logger however Reflection.caller will be removed and it is not a performant solution.
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
Hello, I didn't know this project. After checking, I dislike the way it intercept (ie print but not write).
I already write an interception code (on write) and it is working without limitation.
However I have to use reflection and reload logback (+- 200ms), the method I ask is just a way to improve performance and maintenance.
I think about another clean solution if logback provides a way to install a hook just after slf4j call, so I can set a thread local.
I also think about checking the stack and looking for a subclass of slf4j logger however Reflection.caller will be removed and it is not a performant solution.