Spring 5 how to use Log4jConfigListener

梦想的初衷 提交于 2020-02-28 06:09:48

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/53868470/spring-5-how-to-use-log4jconfiglistener

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!