@Slf4j
Lombok 의 라이브러리
( 로깅 라이브러리 )
로깅 라이브러리 개요
log4j(치명적인 버그가 있었음)
=>
log4j2
=>
logback ( 개선 방식 )
로깅 라이브러리의 특징
( 1 )
함수호출을 일원화 시켜주는 기능
( 디자인 패턴 : Facade 패턴 )
( 2 )
( 간략정보 : Error → Info → Debug → Warn → Trace : 상세 정보 )
로그 백 설치
https://tinylittlelife.tistory.com/209
// logback 설치 :
// 1) log4jdbc.log4j2.properties, logback-spring.xml 기본 설정 파일 추가
// - log4jdbc.log4j2.properties : sql 로그를 출력하기 위한 설정파일
// - logback-spring.xml : logback 의 다양한 레벨 옵션 설정
정의
클래스 위에 붙이면 사용가능
@Slf4j
public class 클래스명 {}
< 함수 >
log.debug()
( 간략정보 : Error → Info → Debug → Warn → Trace : 상세 정보 )
log.debug(값)
예제
@Slf4j
@Controller
public class DeptController {
// TODO : mvc 의 model (service 클래스) 가져오기
@Autowired
DeptService deptService;
@GetMapping("경로")
public String getDeptAll(Model model) {
List<Dept> list = deptService.findAll();
model.addAttribute("list",list);
// TODO : 로그 찍기
log.debug(list.toString());
return "jsp 경로";
}
} // end of class
'SpringBoot > code' 카테고리의 다른 글
SpringBoot - @ResponseBody (1) | 2023.10.10 |
---|---|
SpringBoot - model - 등록일 수정일 추가 (0) | 2023.10.10 |
SpringBoot - Logback , Log4jdbc (로깅) 설정 (0) | 2023.10.06 |
SpringBoot - ResponseEntity (클래스) (1) | 2023.10.06 |
SpringBoot - @RequestBody (0) | 2023.10.06 |