简体   繁体   中英

Change logging.properties file to a different path in Slf4j

Currently i am using slf4j for my application logging which is a tomcat webapp.

I have placed my logging.properties file in tomcat/conf/logging.properties and it is working fine.

I am trying to modify the path of this logging.properties to another location outside tomcat. What change needs to be done in my web application so that tomcat picks the logging configuration from that location.

I have tried setting it to classpath but of no use.

System.setProperty("java.util.logging.config.file", "C://temp//logging.properties");

According to the docs , this ...

java -Djava.util.logging.config.file=myLoggingConfigFilePath 

... is the correct way of pointing JUL to a specific configuration file.

So, if this ...

System.setProperty("java.util.logging.config.file", "C://temp//logging.properties");

... is not causing JUL to use C://temp//logging.properties then it's likely that the logging sub system has already initialised itself before you set that system property.

The most foolproof way of setting that system property is to run the JVM with a -D argument ...

java -Djava.util.logging.config.file=C://temp//logging.properties

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM