簡體   English   中英

log4J找不到JAR使用的屬性文件

[英]log4J Not Finding Properties file Used by JAR

我們有一個從Windows中的命令提示符運行的JAR,它具有log4J的以下參數:

-Dlog4.properties.file=C:/[folderName]/apps/[appName]/config/log4j.properties

即使log4j.properties文件確實在上面的路徑中,log4j也找不到它,因此無法正確配置,並且使用參數-Dlog4j.debug運行命令不會給我更多信息:

log4j: Trying to find [log4j.xml] using context classloader sun.misc.Launcher$Ap pClassLoader@92e78c. log4j: Trying to find [log4j.xml] using sun.misc.Launcher$AppClassLoader@92e78c class loader. log4j: Trying to find [log4j.xml] using ClassLoader.getSystemResource(). log4j: Trying to find [log4j.properties] using context classloader sun.misc.Laun cher$AppClassLoader@92e78c. log4j: Trying to find [log4j.properties] using sun.misc.Launcher$AppClassLoader@ 92e78c class loader. log4j: Trying to find [log4j.properties] using ClassLoader.getSystemResource(). log4j: Could not find resource: [null]. log4j:WARN No appenders could be found for logger (com.xxx.yyy.appName.Main). log4j:WARN Please initialize the log4j system properly.

我覺得我缺少基本的東西,所以我願意接受想法...

簡短的介紹到log4j ,僅當屬性不在類路徑上時,才嘗試在路徑上使用file:作為前綴。 該屬性也稱為log4j.configuration因此您的JVM參數應采用以下形式:
-Dlog4.configuration=file:/c:/[...]/log4j.properties

試試這個參數:

-Dlog4j.configuration=file:///C:/[folderName]/apps/[appName]/config/log4j.properties

看來我的問題是由於Java版本不匹配所致。 該應用程序當前僅在1.5上運行,因此我相應地構建了JAR。 但是其中一個依賴項(即另一個JAR)是使用1.6構建的。 用1.5構建了另一個JAR,問題消失了。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM