Change location of log4j.properties

2019-01-03 10:02发布

I want to put all my config files in a /config subfolder of my application directory. Log4j is expecting the log4j.properties file in the root folder of my application. Is there a way to tell log4j where to look for the properties file?

标签: java log4j
7条回答
戒情不戒烟
2楼-- · 2019-01-03 10:58

You must use log4j.configuration property like this:

java -Dlog4j.configuration=file:/path/to/log4j.properties myApp

If the file is under the class-path (inside ./src/main/resources/ folder), you can omit the file:// protocol:

java -Dlog4j.configuration=path/to/log4j.properties myApp
查看更多
登录 后发表回答