본문 바로가기

Springboot

[spring boot] 로거를 Log4j2로 변경하기

docs.spring.io/spring-boot/docs/current/reference/html/howto-logging.html#howto-configure-log4j-for-logging

 

“How-to” Guides

Spring Boot has no mandatory logging dependency, except for the Commons Logging API, which is typically provided by Spring Framework’s spring-jcl module. To use Logback, you need to include it and spring-jcl on the classpath. The recommended way to do th

docs.spring.io

 

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <exclusions>
                <!-- 기존의 로깅을 빼고 -->
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <!-- log4j 추가 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-log4j2</artifactId>
        </dependency>

로거를 커스텀하고 해뒀더라면, 혹은 하고 싶다면,

기존의 logback-spring.xml 파일의 이름을 log4j2-spring.xml 바꾸면 된다.

'Springboot' 카테고리의 다른 글

[spring boot] 정적 리소스 지원  (0) 2021.01.10
[spring boot] HttpMessageConverters  (0) 2021.01.10
[spring boot] Test  (0) 2021.01.09
[spring boot] logging 커스터마이징  (0) 2021.01.08
[spring boot] logging 기본 설정  (0) 2021.01.08
@Profile  (0) 2021.01.08