我已经创建了spring boot应用程序,并且使用嵌入式Tomcat(必须在JVM中添加catalina.home)时,日志看起来很好。但是在外部Tomcat上部署应用程序后,没有日志记录为Hello _ *。log。 这是我的Log4j配置文件:
<?xml version="1.0" encoding="UTF-8"?>
<Configuration monitorInterval="60" status="WARN">
<Properties>
<Property name="log-path">applogs</Property>
</Properties>
<Appenders>
<Console name="Console-Appender" target="SYSTEM_OUT">
<PatternLayout>
<pattern>
%d{dd-MMM-yyy HH:mm:ss.SSS} [%-5level] [%pid] [%t] %c{1.} - %msg%n
</pattern>
</PatternLayout>
</Console>
<File name="Hello"
fileName="${sys:catalina.home}/logs/Hello_${date:yyyy-MM-dd}.log" >
<PatternLayout>
<pattern>
%d{dd-MMM-yyy HH:mm:ss.SSS} [%-5level] [%pid] [%t] %c{1.} - %msg%n
</pattern>
</PatternLayout>
</File>
<File name="Hello-Error"
fileName="${sys:catalina.home}/logs/Hello_error_${date:yyyy-MM-dd}.log" >
<PatternLayout>
<pattern>
%d{dd-MMM-yyy HH:mm:ss.SSS} [%-5level] [%pid] [%t] %c{1.} - %msg%n
</pattern>
</PatternLayout>
</File>
</Appenders>
<Loggers>
<Logger name="org.springframework" level="INFO" />
<Logger name="org.springframework.ws.server" level="INFO" />
<Logger name="org.apache" level="WARN" />
<Logger name="org.apache.catalina.startup" level="INFO" />
<Logger name="com.hello" level="INFO" />
<Root>
<AppenderRef ref="Console-Appender" />
<!-- Log all messages to the file Hello_<date>.log -->
<AppenderRef ref="Hello" level="INFO" />
<!-- Log all messages with a level >= WARNING to the separate file Hello_error_<date>.log -->
<AppenderRef ref="Hello-Error" level="WARN" />
</Root>
</Loggers>
</Configuration>