日志写入服务器日志而不是应用程序日志

时间:2015-07-14 11:45:10

标签: logging log4j jetty slf4j

在我在Jetty上运行的java web-app中,日志开始被写入服务器(Jetty)日志而不是应用程序日志。我希望看到我的日志写入logs / appLog.log但由于某种原因我只看到它们被写入Jetty的默认日志。是什么导致的?我该如何解决?

这是我的log4j.xml文件:

<appender name="fileAppenderInfo" class="org.apache.log4j.RollingFileAppender">
    <param name="append" value="false" />
    <param name="file" value="logs/appLog.log" />
    <param name="MaxBackupIndex" value="30" />
    <layout class="org.apache.log4j.PatternLayout">
        <param name="ConversionPattern" value="%d{dd MMM yyyy HH:mm:ss} %5p %c{1} - %m%n" />
    </layout>
</appender>

<appender name="fileAppenderErrors" class="org.apache.log4j.RollingFileAppender">
    <param name="append" value="false" />
    <param name="file" value="logs/error/errorLog.log" />
    <param name="MaxBackupIndex" value="30" />
    <param name="threshold" value="ERROR" />
    <layout class="org.apache.log4j.PatternLayout">
        <param name="ConversionPattern" value="%d{dd MMM yyyy HH:mm:ss} %5p %c{1} - %m%n" />
    </layout>
</appender>

<logger name="com.amazonaws">
    <level value="ERROR" />
</logger>


<logger name="org.springframework">
    <level value="ERROR" />
</logger>

<root>
    <level value="INFO" />
    <appender-ref ref="fileAppenderInfo" />
    <appender-ref ref="fileAppenderErrors" />
</root>

以下是我的记录器maven依赖项:

<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-api</artifactId>
    <version>1.7.5</version>
</dependency>
<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>jcl-over-slf4j</artifactId>
    <version>1.7.5</version>
    <scope>runtime</scope>
</dependency>
<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-log4j12</artifactId>
    <version>1.7.5</version>
    <scope>runtime</scope>
</dependency>

0 个答案:

没有答案