问题描述
以前用spring 4.3.8版本,我曾经像下面的代码一样在 web.xml 中进行 Log4j 配置,
<context-param> <param-name>log4jConfigLocation</param-name> <param-value>classpath:/log4j-${spring.profiles.active}.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class> </listener>
目前,我尝试使用 spring 5.0.7 版本,但是我不能使用 Log4jConfigListener
我意识到 Spring 5.x 版本中不存在 Log4jConfigListener
我可以使用"log4j.xml"(默认名称),但我想为服务器、本地环境使用自定义名称
我该怎么办?
Log4jConfigListener 自 Spring 4.2.1 起已被删除,以支持 Apache Log4j 2.
查看相关资料Spring4.2.1 弃用列表:
<块引用>org.springframework.web.util.Log4jConfigListener
从 Spring 4.2.1 开始,支持 Apache Log4j 2(遵循 Apache 对 log4j 1.x 的 EOL 声明)
您可以使用 环境查找一个>.
问题描述
In the past, i used to spring 4.3.8 version, i used to Log4j config in web.xml like below code,
<context-param> <param-name>log4jConfigLocation</param-name> <param-value>classpath:/log4j-${spring.profiles.active}.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class> </listener>
Currently, i trying to use spring 5.0.7 version but, i can't use Log4jConfigListener
i realized Log4jConfigListener is not exist in spring 5.x version
I can use "log4j.xml"(default name) but i want to use custom name for sever,local environment
how can i do?
推荐答案
The Log4jConfigListener has been removed as of Spring 4.2.1, in favor of Apache Log4j 2.
See the relevant information Spring 4.2.1 deprecation list:
org.springframework.web.util.Log4jConfigListener
as of Spring 4.2.1, in favor of Apache Log4j 2 (following Apache's EOL declaration for log4j 1.x)
You can configure environments in the XML file using Environment Lookup.