File tree Expand file tree Collapse file tree
spring-boot-logback/src/main
java/io/ymq/logback/controller Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3030
3131### spring-boot-logback
3232
33- [ Spring Boot 中使用 logback 笔记未更新 ] ( )
33+ [ Spring Boot 中使用 logback 配置 ] ( http://www.ymq.io/2017/10/30/spring-boot-logback-example/ )
Original file line number Diff line number Diff line change 1717@ RequestMapping (value = "/index" )
1818public class IndexController {
1919
20- private static final Logger LOGGER = LoggerFactory .getLogger (IndexController . class );
20+ private final Logger LOGGER = LoggerFactory .getLogger (this . getClass () );
2121
2222 /**
23- * http://127.0.0.1:/index/?content="我是测试内容"
23+ * http://127.0.0.1:8080 /index/?content="我是测试内容"
2424 *
2525 * @param content
2626 * @return
@@ -30,7 +30,11 @@ public class IndexController {
3030 public String index (@ RequestParam String content ) {
3131 LocalDateTime localDateTime = LocalDateTime .now ();
3232
33+ LOGGER .trace ("请求参数:content:{}" , content );
34+ LOGGER .debug ("请求参数:content:{}" , content );
3335 LOGGER .info ("请求参数:content:{}" , content );
36+ LOGGER .warn ("请求参数:content:{}" , content );
37+ LOGGER .error ("请求参数:content:{}" , content );
3438
3539 return localDateTime + ",content:" + content ;
3640 }
Original file line number Diff line number Diff line change 11spring.application.name =spring-boot-logback
22
3- server.port =80
3+ server.port =8080
4+
5+ # 日志级别从低到高分为TRACE < DEBUG < INFO < WARN < ERROR < FATAL,如果设置为WARN,则低于WARN的信息都不会输出
6+ logging.level.root =debug
7+
8+ logging.path =/data/logs/spring-boot-logback
Original file line number Diff line number Diff line change 22<configuration >
33
44 <!-- 日志根目录-->
5- <springProperty scope =" context" name =" LOG_HOME" source =" log.home " defaultValue =" /data/logs/spring-boot-logback" />
5+ <springProperty scope =" context" name =" LOG_HOME" source =" logging.path " defaultValue =" /data/logs/spring-boot-logback" />
66
77 <!-- 日志级别 -->
8- <springProperty scope =" context" name =" LOG_ROOT_LEVEL" source =" log .level" defaultValue =" DEBUG" />
8+ <springProperty scope =" context" name =" LOG_ROOT_LEVEL" source =" logging .level.root " defaultValue =" DEBUG" />
99
1010 <!-- 标识这个"STDOUT" 将会添加到这个logger -->
1111 <springProperty scope =" context" name =" STDOUT" source =" log.stdout" defaultValue =" STDOUT" />
You can’t perform that action at this time.
0 commit comments