我有一个包含以下清单的 jar 文件
Manifest-Version: 1.0
Created-By: 1.7.0_07 (Oracle Corporation)
Main-Class: test.Main
Class-Path: ./log4j.properties lib/log4j-1.2.17.jar
我按如下方式运行该类
java -jar test.jar
这是我的文件夹
lib
log4j.properties
test.jar
为什么我看不到 log4j 属性文件?这就是我所看到的
log4j:WARN No appenders could be found for logger (test.Main).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
谢谢
解决方案:
将 MANIFEST 中的 classhpath 更改为此
Class-Path: . lib/log4j-1.2.17.jar
您还可以使用参数启动 JVM:
-Dlog4j.configuration=file:"./your/properties/path/log4j.properties"
指定外部日志属性的任意位置。我在一个特定项目中多次使用了这一点。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)