JunsuLime / spring-cloud-native-explorer

Spring cloud explorer
1 stars 0 forks source link

logback 을 적용하자. #42

Open JunsuLime opened 2 years ago

JunsuLime commented 2 years ago

spring logging 에서는 application properties 를 설정하여 로깅 설정하는 법을 알려주고 있다. logback 의 custom 한 설정을 활용하기 위해서는

https://docs.spring.io/spring-boot/docs/current/reference/html/features.html#features.logging.custom-log-configuration 여기를 참고하자.

Since logging is initialized before the ApplicationContext is created, it is not possible to control logging from @PropertySources in Spring @Configuration files. The only way to change the logging system or disable it entirely is through System properties.

logback 을 사용할 경우

이런 파일들로 설정가능하다.

참고로 spring. 에서는 -spring surfix 를 붙이는걸 권장한다.

When possible, we recommend that you use the -spring variants for your logging configuration (for example, logback-spring.xml rather than logback.xml). If you use standard configuration locations, Spring cannot completely control log initialization.

JunsuLime commented 2 years ago

Spring logback extension 에 대해서. (spring 에서 logback 을 어떻게 사용하는가?)

https://docs.spring.io/spring-boot/docs/current/reference/html/features.html#features.logging.logback-extensions

spring 에서는 https://github.com/spring-projects/spring-boot/blob/v2.6.1/spring-boot-project/spring-boot/src/main/resources/org/springframework/boot/logging/logback/defaults.xml

를 기본 설정으로 제공해주고 있다.

JunsuLime commented 2 years ago

logback 의 설정을 logback 문서를 통해서 확인하자. http://logback.qos.ch/manual/configuration.html#syntax

흠냐 근데 개념을 알기 위해서 http://logback.qos.ch/manual/introduction.html 문서 시작부터 한번 훑어보기는하자.

Architecture of logback

logger 는 naming 으로 계층이 표현된다.

Named Hierarchy A logger is said to be an ancestor of another logger if its name followed by a dot is a prefix of the descendant logger name. A logger is said to be a parent of a child logger if there are no ancestors between itself and the descendant logger.

JunsuLime commented 2 years ago

에러로그와 일반로그를 구분해서 로깅하자.