问题描述
如何通过?我能让它工作的唯一方法是将log4j.xml放在类路径上。
how to pass? The only way I can get this to work is to put log4j.xml on the classpath.
传递:命令行上的-Dlog4j.configuration = file:/// c:\ log4j2.xml不起作用(尽管它在非弹簧中运行) - 启动测试应用程序就好了。
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.
推荐答案
尝试将此行放入 application.properties
:
logging.config=file:log4j.xml
第二个选项是将系统变量传递给 -Dlogging.config = file:log4j.xml
Second option is to pass system variable to -Dlogging.config=file:log4j.xml
在这种情况下,它是预期的位于JAR文件之外的当前目录中。
In this case it is expected to be located in current directory outside of the JAR file.
这篇关于jar外部的spring boot log4j文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!