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

标签 java logging log4j

我正在 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/

相关文章:

java - Protobuf android : Migration to AndroidX : cannot find symbol class EnumVerifier

java - 将包传递给设置为单任务的 Activity

python - 将自定义格式化程序类与 Python 的 logging.config 模块一起使用

java - 如何从我的应用程序获取日志文件名。属性文件

java - 避免启用 Log4j/Slf4j 调试检查

java - 如何将 log4j.properties 文件转换为 log4j2.xml 或 log4j2.properties 文件

java - 如何使用 Android 在 RecyclerView 中显示来自 Firestore 的数据?

java - 如何以编程方式在 Android Cupcake 中启用 GPS

logging - 全局日志记录的正确方法

debugging - 彩色 grep 的等价物是什么?