Spring 5 how to use Log4jConfigListener

10,950

Solution 1

Just Remove the listener from web.xml and put log4j.properties file in your classpath. then you will get your result.

Solution 2

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.

Solution 3

org.springframework.web.util.Log4jConfigListener is deprecated as of Spring 4.2.1, in favor of Apache Log4j 2 (following Apache's EOL declaration for log4j 1.x)

as an alternate you can change your configuration to use org.apache.logging.log4j.web.Log4jServletContextListener (log4j-web) More details can be found here https://logging.apache.org/log4j/2.x/manual/webapp.html

Share:
10,950

Related videos on Youtube

jeongwon heo
Author by

jeongwon heo

Updated on October 14, 2022

Comments

  • jeongwon heo
    jeongwon heo over 1 year

    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?

  • johnlinp
    johnlinp almost 3 years
    Any concrete example of how I can use "Environment Lookup" to replace Log4jConfigListener?