0
votes

I am getting error 'ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.' while executing ant target : instrument.

My ANT target :

<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>

My project configuration :

ANT : 1.7

struts : 2.3.24

spring: 4.2.3

hibernate:4.2.8

I have tried below solutions:

1) changed property -Dlog4j.configuration to -Dlog4j.configurationFile

2) put the log4j2.xml file under src folder

3) add sysproperty in build script

4) set classpath to log4j2.xml

Questions :

1) If the errors in log4j2.xml will cause this error or it is only because log4j2.xml is not available while compiling?

2) Is there any tool available to validate my log4j2.xml?

3) Is there any ANT related dependency or ANT upgrade require?

Thanks

3

3 Answers

0
votes

I have a project with Ant and log4j and my target who calls a defined macri macrodef where i call my log4j

<java classname="YourMainClass.java or otherclass.java">
    <sysproperty key="log4j.configuration" value="log4j.properties" />
<java/>

Inside. I don't have a log4j2.xml

0
votes

1) This error happened when log4j 2 can't find the log4j2.xml file. I use the jvmarg element to set the property Dlog4j.configurationFile:

<java classname="xxx"> <jvmarg value="-Dlog4j.configurationFile=log4j_build.xml"/> </java>

The path of the log4j2.xml file is define with the element path and pathelement of ANT.

2) No, there isn't any tools or XSD to validate the log4j2.xml file. To debug your configuration file, you can print the internal trace of log4j 2 with the property -Dorg.apache.logging.log4j.simplelog.StatusLogger.level=TRACE and with the attribute status in the configuration file : <Configuration status="trace">.

3) I use the last version of ANT, but I don't have any others dependencies.

0
votes

You could try to copy the file log4j2.xml to the working directory of the user, i.e.:

<copy todir="${user.dir}" overwrite="true" verbose="true">
    <fileset dir="${srcFolder}">
        <include name="**/*.*" />
    </fileset>
</copy>

You need to have the file in the srcFolder in order to be included.