posted by 귀염둥이채원 2019. 3. 29. 18:19

1. application.properties 파일에 log 설정

logging.level.root=INFO 
logging.level.com.example.demo=ERROR 


2. HelloController.java 추가

package com.example.demo.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {

	private static final Logger logger = LoggerFactory.getLogger(HelloController.class);
	
	@RequestMapping("/")
	public String index() {
		return "hello world!";
	}

	@RequestMapping("/log")
	public String log() {
		logger.debug("debug log");
		logger.info("info log");
		logger.warn("warn log");
		logger.error("error log");
		return "hello world!";
	}
}

 

'Spring Boot' 카테고리의 다른 글

[Spring Boot] MyBatis + Mysql 샘플2  (0) 2019.03.29
[Spring Boot] MyBatis + Mysql 샘플  (0) 2019.03.29
DAO, DTO, VO란?  (0) 2019.03.28
스프링 MVC 패턴이란?  (0) 2019.03.28
WEB MVC HelloWorld  (0) 2019.03.28