Spring Boot Logging

목차

Spring Boot Logging

로그 선언 방법

  • private final Logger log = LoggerFactory.getLogger(getClass());
  • private static final Logger log = LoggerFactory.getLogger(xxx.class);
  • @slf4j // Lombok에서 제공하는 Log 기능 사용
log.trace("info log = {}", name);
log.debug("info log = {}", name);
log.info("info log = {}", name);
log.warn("info log = {}", name);
log.error("info log = {}", name);
logging.level.com.example.springmvc=trace 
@Slf4j
@RestController
public class LogTestController {

// private final Logger log = LoggerFactory.getLogger(getClass());

@RequestMapping("/log-test")
public String logTest(){
String name = "Spring";
System.out.println("name = " + name);
log.trace("info log = {}", name);
log.debug("info log = {}", name);
log.info("info log = {}", name);
log.warn("info log = {}", name);
log.error("info log = {}", name);

return "ok";
}
}

Share