How to use log4j with Spring 5?

Viewed 9889

I have troubled with using Log4j in Spring 5. In the past, I used Log4j in Spring like this:

<context-param>
    <param-name>log4jConfigLocation</param-name>
    <param-value>/WEB-INF/config/log4j.properties</param-value>
</context-param>
<listener>
    <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>

And now, I want to use Log4j in Spring 5, but there is no class named 'org.springframework.web.util.Log4jConfigListener'. What can I do?

2 Answers

According to Spring 4.2.1 documentation, Log4jConfigListener is deprecated in favor of Apache Log4j 2 (following Apache's EOL declaration for log4j 1.x). So, I've removed section with this class from web.xml and then everything went fine. Also I've added log4j.properties to the "util:properties" section of applicationContext.xml.

Related