728x90
pom.xml 에서 log4j -> log4j2 설정 방법
- log4j2 dependency 추가
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.30</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.12.1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.12.1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.12.1</version>
</dependency>
- log4j2.xml 추가
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
<Appenders>
<Console name="STDOUT" target="SYSTEM_OUT">
<PatternLayout pattern="%-5p | %d{yyyy-MM-dd HH:mm:ss} | [%t] %C{2} (%F:%L) - %m%n"/>
</Console>
</Appenders>
<Loggers>
<Root level="info">
<AppenderRef ref="STDOUT"/>
</Root>
</Loggers>
</Configuration>
pom.xml 에서 log4j -> logback 설정 방법
- logback 관련 dependecy 추가
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>1.2.3</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.30</version>
</dependency>
- mvn dependency:tree 로 log4j, slf4j 관련 dependency 를 찾아서 exclusion 처리
- logback.xml 추가
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="STD_OUTPUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<root>
<level value="INFO" />
<appender-ref ref="STD_OUTPUT" />
</root>
</configuration>
'Engineering > Java' 카테고리의 다른 글
gradle multi build for war (0) | 2020.10.05 |
---|---|
logger info {} 사용 (0) | 2020.08.06 |
InteliJ 설치 후 Lombok 설정 (0) | 2019.11.06 |
CompletableFuture 기능 살펴보기 (0) | 2019.08.23 |
java 8 stream API 실행시간 비교 (0) | 2019.08.22 |