为什么我的tomcat找不到log4j.properties文件?

时间:2019-10-25 12:27:42

标签: java tomcat log4j antbuilder

我有一个带有和ant构建的servlet。我产生了战争并将其部署在tomcat中,一切似乎都很好,但是当我尝试通过GET调用服务时,出现以下错误:

log4j:ERROR Could not read configuration file [log4j.properties]

我看不到这里会发生什么。

这是我的tomcat文件夹的结构:

WEB-INF
 |- classes
      |- log4j.properties
      |- servletConnector.class
 |- lib
 |- web.xml

蚂蚁构建文件如下所示:

<?xml version="1.0" encoding="UTF-8"?>

<property name="app.name" value="amadeus1"/>
<property name="target.home" value="${basedir}/target"/>
<property name="war.home" value="${basedir}/war"/>
<property name="src.home" value="${basedir}"/>
<property name="webapp.home" value="${basedir}/src/main/webapp"/>
<property name="libs.home" value="${basedir}/lib"/>
<property name="config.home" value="${basedir}/config"/>
<property name="env" value="des"/>

<target name="help">
<echo>-- TCP Conectividad --</echo>
<echo> </echo>
<echo> help : (default) Prints this message </echo>
<echo> all : Cleans, compiles, and packages application</echo>
<echo> clean : Deletes work directories</echo>
<echo> compile : Compiles servlets into class files</echo>
<echo> dist : Packages artifacts into a deployable WAR</echo>
<echo></echo>
<echo>For example, to clean, compile, and package all at once, run:</echo>
<echo>prompt> ant all </echo>
</target>

<presetdef name="javac">
    <javac includeantruntime="false" />
</presetdef>

<path id="compile.classpath">
    <pathelement location="${libs.home}"/>
    <fileset dir="${libs.home}">
        <include name="*.jar"/>
    </fileset>
</path>

<target name="all" depends="clean,compile,dist"
        description="Clean work dirs, then compile and create a WAR"/>

<target name="clean"
        description="Delete old work and dist directories">
    <delete dir="${target.home}/${app.name}"/>
    <delete dir="${war.home}"/>
</target>

<target name="prepare" depends="clean"
        description="Create working dirs and copy static files to work dir">
    <mkdir dir="${war.home}"/>
    <mkdir dir="${target.home}/${app.name}/WEB-INF/classes"/>
    <copy todir="${target.home}/${app.name}/WEB-INF/lib">
        <fileset dir="${libs.home}"/>
    </copy>
    <copy todir="${target.home}/${app.name}/WEB-INF/">
        <file name="${config.home}/${env}/web.xml" />
    </copy>
    <copy todir="${target.home}/${app.name}/WEB-INF/classes">
        <file name="${config.home}/${env}/log4j.properties" />
    </copy>
</target>

<target name="compile" depends="prepare"
    description="Compile Java sources and copy to WEB-INF/classes dir">
    <javac srcdir="${src.home}"
        destdir="${target.home}/${app.name}/WEB-INF/classes">
        <classpath refid="compile.classpath"/>
    </javac>
</target>

<target name="dist" depends="compile"
    description="Create WAR file for binary distribution">
    <jar jarfile="${war.home}/${app.name}.war"
    basedir="${target.home}/${app.name}"/>
</target>

我已经尝试将log4j.properties放在相同级别的web.xml中,并且遇到相同的错误。

0 个答案:

没有答案