![](/img/trans.png)
[英]ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console
[英]ERROR StatusLogger No log4j2 configuration file found. Using default configuration while compiling using ANT target
我收到錯誤消息'ERROR StatusLogger找不到log4j2配置文件。 使用默認配置:僅將錯誤記錄到控制台。 執行螞蟻目標:儀器時 。
我的ANT目標:
<target name="instrumentHibernate">
<taskdef name="instrument" classname="org.hibernate.tool.instrument.javassist.InstrumentTask">
<classpath>
<path refid="all_classpath"/>
</classpath>
</taskdef>
<instrument verbose="true">
//Error is thrown at this block
<fileset dir="target/classes" includes="**/A.class" />
<fileset dir="target/classes" includes="**/B.class" />
<fileset dir="target/classes" includes="**/C.class" />
</instrument>
</target>
螞蟻:1.7
支撐桿:2.3.24
春季:4.2.3
休眠狀態:4.2.8
1)將屬性-Dlog4j.configuration更改為-Dlog4j.configurationFile
2)將log4j2.xml文件放在src文件夾下
3)在構建腳本中添加sysproperty
4)將類路徑設置為log4j2.xml
1)如果log4j2.xml中的錯誤將導致此錯誤,或者僅是因為在編譯時log4j2.xml不可用?
2)有沒有可用的工具來驗證我的log4j2.xml?
3)是否有任何與ANT相關的依賴關系或ANT升級要求?
謝謝
我有一個使用Ant和log4j的項目,我的目標調用了定義的macri macrodef
,在其中我將我的log4j稱為
<java classname="YourMainClass.java or otherclass.java">
<sysproperty key="log4j.configuration" value="log4j.properties" />
<java/>
內。 我沒有log4j2.xml
1)當log4j 2找不到log4j2.xml文件時,發生此錯誤。 我使用jvmarg元素設置屬性Dlog4j.configurationFile:
<java classname="xxx"> <jvmarg value="-Dlog4j.configurationFile=log4j_build.xml"/> </java>
log4j2.xml文件的路徑是使用ANT的元素路徑和pathelement定義的。
2)不,沒有任何工具或XSD可以驗證log4j2.xml文件。 要調試配置文件,可以使用屬性-Dorg.apache.logging.log4j.simplelog.StatusLogger.level = TRACE以及屬性狀態在配置文件中打印log4j 2的內部跟蹤: <Configuration status="trace">
。
3)我使用的是ANT的最新版本,但是沒有其他依賴項。
您可以嘗試將文件log4j2.xml
復制到用戶的工作目錄,即:
<copy todir="${user.dir}" overwrite="true" verbose="true"> <fileset dir="${srcFolder}"> <include name="**/*.*" /> </fileset> </copy>
您需要將文件包含在srcFolder
中才能被包含。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.