问题描述
从命令行中运行" java pakcage.main"时,我的log4j工作正常,但是当我使用可执行的jar(例如" java -jar myjar.jar.jar")运行相同的程序时P>
log4j:WARN No appenders could be found for logger log4j:WARN Please initialize the log4j system properly
log4j.jar和log4j.properties在我的清单的Class-Path中.
我确定它可以正常工作,但是重建后它无法正常工作.
推荐答案
您只能将JAR文件或目录列出为类路径的一部分.而不是指定log4j.properties,您应该指定属性文件与正在执行的JAR中的目录.
示例:
如果myjar.jar在基本目录中
myjar.jar中的类路径条目如下
class-path:lib/log4j.jar conf/
其他推荐答案
我相信您还应该能够在自定义JAR文件的内部包含log4j.xml(或log4j.properties)文件.只要它位于Jar文件的根部,Log4J框架就可以找到它.
其他推荐答案
这有帮助吗?
http://marc.info/marc.info/? 3
问题描述
My log4j is working fine when I run "java pakcage.Main" from command line, but when I run the same program using executable jar like "java -jar myjar.jar" I'm getting the following err:
log4j:WARN No appenders could be found for logger log4j:WARN Please initialize the log4j system properly
log4j.jar and log4j.properties are threre in my manifest's Class-Path.
I'm sure it worked properly once, but after rebuild it is not working.
推荐答案
You can only list jar files or directories as part of a classpath. Instead of specifying log4j.properties you should specify the directory that the properties file is in relative to the jar being executed.
Example:
If myjar.jar in the base directory, log4j.jar in ./lib/ and log4j.properties in ./conf/
The Class-Path entry in myjar.jar as follows
Class-Path: lib/log4j.jar conf/
其他推荐答案
I believe you should also be able to simply include your log4j.xml (or log4j.properties) file inside of your custom Jar file. As long as it is in the root of your Jar file, the log4j framework will be able to find it.
其他推荐答案
Does this help ?