복붙노트

[SPRING] Spring 5.0.2의 Log4jConfigurer

SPRING

Spring 5.0.2의 Log4jConfigurer

저는 Spring 4.X.X를 사용하고 아래의 설정을 사용하여 Log4j를 구성했습니다. 이제 Log4jConfigurer 클래스가 제거 된 Spring 5.0.2로 업그레이드 중입니다. Spring 5.0.2에서 어떻게 할 수 있습니까?

<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>classpath:log4j.properties</value>
        </list>
    </property>
</bean>

해결법

  1. ==============================

    1.Log4JConfigurer는 기본이 아닌 Log4j 초기화에 필요합니다. 사용자 정의 설정 파일 이름 / 위치를 사용하는 경우 설정 파일이 기본 위치 인 classpath : log4j.properties에 있으므로 Log4jConfigurer 선언을 제거하면 Spring에서 log4j.properties를 자동으로 검색합니다.

    Log4JConfigurer는 기본이 아닌 Log4j 초기화에 필요합니다. 사용자 정의 설정 파일 이름 / 위치를 사용하는 경우 설정 파일이 기본 위치 인 classpath : log4j.properties에 있으므로 Log4jConfigurer 선언을 제거하면 Spring에서 log4j.properties를 자동으로 검색합니다.

    여기서 한 가지주의 할 점이 있습니다. Spring 5는 Log4j v2 (Log4j 1.x에 대한 Apache의 EOL 선언 다음)를 사용하므로 Log4j v2를 사용하는 동안 Spring 5는 Log4JConfigurer를 선언 할 필요없이 log4j.properties 파일을 자동으로 감지합니다. 현재 Log4j v2를 사용하고 있지 않다면, Spring 5가 Log4j v1.x의 사용을 지원하지 않으므로 업그레이드가 필요하다고 생각합니다.

  2. from https://stackoverflow.com/questions/48107537/log4jconfigurer-in-spring-5-0-2 by cc-by-sa and MIT license