spring boot log4j file external to jar?

2019-01-28 01:41发布

how to pass? The only way I can get this to work is to put log4j.xml on the classpath.

passing: -Dlog4j.configuration=file:///c:\log4j2.xml on the command line doesn't work (although it does in a non spring-boot test application just fine).

I also tried putting this as an environment variable/property in spring.

2条回答
老娘就宠你
2楼-- · 2019-01-28 02:15

Try to put this line into your application.properties:

logging.config=file:log4j.xml

Second option is to pass system variable to -Dlogging.config=file:log4j.xml

In this case it is expected to be located in current directory outside of the JAR file.

查看更多
Deceive 欺骗
3楼-- · 2019-01-28 02:15

you must put the "-Dlog4j" before the "-jar XXXX.jar".i try it my own .work for me.

查看更多
登录 后发表回答