Reputation: 2910
I have a logback.xml
in the resources folder of my java web application which is running on Tomcat 7. Is there a way to change the debug level of some class of the application dynamically as the application is running?
The standard thing to do it is a normal java jar running from the CLI is to just edit logback.xml
with say vim and after a while the log is updated. Is this possible with tomcat as I tried it and id does not seem to work.
Is there any better way?
Upvotes: 1
Views: 2500
Reputation: 4543
You can try like this is your application to change the level:
Logger root = (Logger)LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
root.setLevel(Level.INFO);
For specifying the package name as logger-name.
LoggerContext loggerContext = (LoggerContext)LoggerFactory.getILoggerFactory();
Logger myPackageLogger = loggerContext.getLogger("com.mypackage");
myPackageLogger.setLevel(Level.INFO);
Upvotes: 5