我正在尝试使用slf4j-log4j12为我的应用实现日志记录跟踪。我已经配置了所有内容,并且在我以独立模式进行测试时它运行良好。现在我已经在tomcat中部署了它,它停止了工作!它只是在控制台中打印日志(甚至是我用slf4j创建的日志),但不在文件中打印!
这是我的log4j.xml:
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<appender name="fileAppender" class="org.apache.log4j.RollingFileAppender">
<param name="Threshold" value="INFO" />
<param name="File" value="assp.log" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %-5p [%c{1}] %m %n" />
</layout>
</appender>
<appender name="console" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %-5p %c{1} - %m%n" />
</layout>
</appender>
<root>
<priority value="debug" />
<appender-ref ref="fileAppender" />
<appender-ref ref="console" />
</root>
</log4j:configuration>
我的依赖项:
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jul-to-slf4j</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
</dependency>
这是我的测试类
private Logger LOGGER = LoggerFactory.getLogger(Test.class);
@RequestMapping("*")
public String root(RedirectAttributes redirectAttributes){
LOGGER.info("{} - entering root page. Redirecting to index.", System.currentTimeMillis());
return "redirect:/index";
}
输出(在控制台中):
INFO 1404999952210 - entering root page. Redirecting to index.
有人可以帮忙吗? 感谢