Spring Framework/Spring Boot
[Spring Boot] log4j2 로그 레벨별 색 지정
장쫄깃
2024. 7. 16. 20:49
728x90
log4j2.xml
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
<Properties>
<Property name="LOG_LEVEL_PATTERN">{%5p}{FATAL=red blink, ERROR=red bold, WARN=yellow bold, INFO=green bold, DEBUG=blue bold, TRACE=blue}</Property>
</Properties>
<Appenders>
<Console name="console" target="SYSTEM_OUT">
<PatternLayout disableAnsi="false" pattern="%style{%d{MM-dd HH:mm:ss}}{magenta} %highlight${LOG_LEVEL_PATTERN} %style{[%c{1.1.1.*}]}{cyan} %m%n" />
</Console>
</Appenders>
<Loggers>
...
<Root level="INFO">
<AppenderRef ref="console" />
<AppenderRef ref="FILE" />
</Root>
</Loggers>
</Configuration>
결과
로그별 색상이 다르게 출력되는 것을 볼 수 있다.
728x90