我正在 Intellij 中使用以下 jvm 参数运行测试用例
-Xmx2512m -XX:MaxPermSize=512m -Dlog4j.properties=log4j.mllib.properties -Dlog4j.debug
有趣的是
-Dlog4j.debug
属性(property)受到尊重,但是
-Dlog4j.properties is not.
证据?在输出日志文件中我们看到:
log4j: Trying to find [log4j.xml] using context classloader sun.misc.Launcher$AppClassLoader@560dd7a7.
log4j: Trying to find [log4j.xml] using sun.misc.Launcher$AppClassLoader@560dd7a7 class loader.
log4j: Trying to find [log4j.xml] using ClassLoader.getSystemResource().
log4j: Trying to find [log4j.properties] using context classloader sun.misc.Launcher$AppClassLoader@560dd7a7.
log4j: Using URL [file:/shared/pic/mllib/target/scala-2.10/test-classes/log4j.properties] for automatic log4j configuration.
log4j: Reading configuration from URL file:/shared/pic/mllib/target/scala-2.10/test-classes/log4j.properties
..
因此,我们确实看到了 log4j 处理的详细信息(调试级别) - 如 -Dlog4j.debug 所示。但 -Dlog4j.properties 没有得到尊重。
最佳答案
尝试使用-Dlog4j.configuration=file:/log4j.mllib.properties
。
关于java - Log4j 识别 logj4.debug,但不尊重 log4j.properties 设置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28205731/