spring boot 支持的日志框架有
2017-03-22 10:35:50.325 INFO 9220 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2017-03-22 10:35:50.326 INFO 9220 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 5837 ms
2017-03-22 10:35:50.567 INFO 9220 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
ERROR
,WARN
,INFO
,DEBUG
或TRACE
,默认输出INFO
及以上---
#日志路径
logging.file=/var/logs/ly.log
#全局级别
logging.level.*=info
#细粒度级别
logging.level.root=WARN
logging.level.org.springframework.web=DEBUG
logging.level.org.hibernate=ERROR
#日志配置文件
logging.config=classpath:logback-liuyin.xml
Spring Boot默认会加载classpath:logback-spring.xml或classpath:logback-spring.groovy
据说不要用logback.xml文件命名,SpringBoot不能完全实例化这个文件(Spring Boot官方也建议用成logback-*.xml这种形式,而不用logback.xml)
如果不想用logback,而使用log4j2:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j</artifactId>
</dependency>
在classpath添加log4j2.xml或者log4j2-spring.xml(spring boot 默认加载)
内容来源于网络,如有侵权,请联系作者删除!