본문 바로가기

Springboot

[spring boot] logging 커스터마이징

https://docs.spring.io/spring-boot/docs/current/reference/html/howto-logging.html 

 

“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

Customize log file

Logback: 파일 이름으로 resources/logback-spring.xml을 추천한다.

[ logback-spring.xml ]

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <include resource="org/springframework/boot/logging/logback/defaults.xml"/>
    <include resource="org/springframework/boot/logging/logback/console-appender.xml" />
    <root level="INFO">
        <appender-ref ref="CONSOLE" />
    </root>

    <!-- 내가 작성한 클래스들만 DEBUG level로 로깅해줘. -->
    <logger name="com.jueun.demo" level="DEBUG"/>
</configuration>

 

추가로, Logback extension이 있다.

  • 프로파일 <springProfile name=”프로파일”>

  • Environment 프로퍼티 <springProperty>

'Springboot' 카테고리의 다른 글

[spring boot] HttpMessageConverters  (0) 2021.01.10
[spring boot] Test  (0) 2021.01.09
[spring boot] 로거를 Log4j2로 변경하기  (0) 2021.01.08
[spring boot] logging 기본 설정  (0) 2021.01.08
@Profile  (0) 2021.01.08
[spring boot] 외부 설정  (0) 2021.01.08