I need to change my log4j properties (rootLogger, MaxFileSize, etc.) at runtime. How can I do this?
相关问题
- convert logback.xml to log4j.properties
- logging static methods in a parent class
- Wrap log4j or create custom logger?
- ClassNotFoundException found in Log4j 2.0
- Undeploying a Grails App from Glassfish gets a Cla
相关文章
- Can IntelliJ create hyperlinks to the source code
- how can I disable output to log4j.rootLogger?
- Log4j2 using {} against using %d or %s
- How do I redirect a javaw.exe console output to a
- log4j: Standard way to prevent repetitive log mess
- Log4j2 not working in WebLogic 12.2.1
- Grails and Log4J : How to logs in different files
- Managing a Large Number of Log Files Distributed O
Use
LogManager.resetConfiguration();
to clear the current config and configure it again.Another approach is to build a new appender and replace the old one with it (most appenders don't support changing their config). This way, all the loggers (and their levels, etc) stay intact.
For this to work, I usually add the first appender from code (and not with a config file). That allows me to save a reference which makes it more simple to remove it later.
https://github.com/apache/jena/blob/master/jena-tdb/log4j.properties has a log4j properties file.
Based on it I am using the configureLog4j helper function shown below like this:
set jena logging level at runtime
configureLog4J function