Log4j识别logj4.debug,但不尊重log4j.properties设置?

时间:2015-01-29 01:51:12

标签: java logging log4j

我在Intellij中使用以下jvm参数运行测试用例

-Xmx2512m -XX:MaxPermSize=512m -Dlog4j.properties=log4j.mllib.properties -Dlog4j.debug

有趣的是

-Dlog4j.debug

属性正在受到尊重,但是

-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没有得到尊重。

1 个答案:

答案 0 :(得分:1)

请尝试-Dlog4j.configuration=file:/log4j.mllib.properties