1

I had upgraded my project from Spring 4 to Spring 5 and I am resolving the deprecated/removed classes. As part of the effort I had noticed that log4jConfigurer is removed from Spring 5.

I have the following code:

<bean
    class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
    <property name="targetClass" value="org.springframework.util.Log4jConfigurer"/>
    <property name="targetMethod" value="initLogging"/>
    <property name="arguments">
        <list>
            <value>file:///${logPropertyFile}</value>
        </list>
    </property>
</bean>

I am aware of the fact that many had posted a similar question but I don't see any explanation on how to do when I have custom path for the log4j2 configuration file.

I am aware of the fact that we can put it in web.xml file but I want to load a different log file configuration for the child project irrespective of the parent project log configuration. So, Spring context file is best place of it.

I would like to know how to resolve the Log4jConfigurer for custom log file in Spring-5.

Thanks in advance!

Vamsi
  • 619
  • 3
  • 9
  • 22

1 Answers1

0

You could try using the log4j PropertyConfigurator instead?

<property name="targetClass" value="org.apache.log4j.PropertyConfigurator"/>
        <property name="targetMethod" value="configure"/>
        <property name="arguments">
            <list>
                <value>${logPropertyFile}</value>
            </list>
</property>

The configure(String) method is backed by a FileInputStream where typically the path is referenced without using a file: scheme ...

Paul
  • 17
  • 1
  • 4