我的 struts2 和 log4j2.0 有问题我的程序运行正常但 log4j2.0 没有响应请帮助我解决问题。
我使用以下 jar: 1.log4j-core-2.0-beta8 2.log4j-api-2.0-beta8 3.log4j-web-2.0-beta2
我的 log4j2.xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration strict="true" schema="Log4J-V2.0.xsd" status="OFF" monitorInterval="300">
<appenders>
<Console name="CONSOLE" target="SYSTEM_OUT">
<PatternLayout pattern="%d %-5p [%t] %C{2} (%F:%L) - %m%n" />
</Console>
<File name="MyFile" fileName="Logger/knight.log">
<PatternLayout pattern="%d %-5p [%t] %C{2} (%F:%L) - %m%n" />
</File>
</appenders>
<loggers>
<root>
<appender-ref ref="CONSOLE" />
<appender-ref ref="MyFile" />
</root>
</loggers>
</configuration>
我的 web.xml
<?xml version="1.0" encoding="UTF-8"?>
<display-name>Struts2_Verified</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<context-param>
<param-name>log4jConfiguration</param-name>
<param-value>log4j2.xml</param-value>
</context-param>
<listener>
<listener-class>org.apache.logging.log4j.core.web.Log4jContextListener</listener-class>
</listener>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>