<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>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>
logging.config=classpath:log4j2.xml
resource 폴더 에 log4j2.xml 파일 생성.
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="INFO">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</Console>
</Appenders>
<Loggers>
<Root level="INFO">
<AppenderRef ref="Console"/>
</Root>
</Loggers>
</Configuration>
여기서 궁금한것 그램 내가 위에서 적용한 로그 모듈이 log4j2 인지 아니면 기존 Logback 인지 어떻게 알지? 방법은 간단하다. debug 모드로 실행후 임의 포인트를 찍고 로그상태를 확인 해보면 알수 있다.
새로 적용된 Log4j2 경우.
Log4j2 에 큰 버그가 발견 되어 현재 기준 2.17.0 를 사용하라고 명시되어있다고 한다. 하지만 Springboot 2.6.2+ 에서 이미 2.17.0 를 적용하여기때문에 별도의 변경작없이 없도 된다. 또는 2.17.1 이나 더 높은 버전을 사용해도 좋다.