springboot学习笔记(二)日志配置

1.创建资源文件

springboot学习笔记(二)日志配置_第1张图片


设置日志参数:

logging.file=log.log  
logging.level.com.xiaofangtech.sunt.controller = debug  
logging.level.com.xiaofangtech.sunt.helper = warn  



测试类:

/**
 * Test_myspringboot
 * Controller_test.java
 */
package com.springboot.Test_myspringboot;

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

/**
 * @author xuchuang
 * @updateTime 2017年12月20日 下午3:38:31
 */
@RestController
public class Controller_test {
	
	  private final Logger logger = LoggerFactory.getLogger(this.getClass());  
	
	   @RequestMapping("/hello")
	    String home() {
		    logger.debug("This is a debug message");  
	        logger.info("This is an info message");  
	        logger.warn("This is a warn message");  
	        logger.error("This is an error message");  
	        return "Hello World!";
	    }

}


启动后访问 localhost:6636/hello

查看控制台:


springboot学习笔记(二)日志配置_第2张图片




你可能感兴趣的:(springboot)