Spring Boot提供了一套日志系统,目前来看logback是最优先的选择。
springboot集成logback网上的教程很多,因此集成的方式这边就不多说了。我这边主要说下我对日志的几个要求:
a.项目是多环境的每个环境中对日志处理的级别不同
b.每个环境存储日志的路径不同
下面是我的实现步奏:
1.在resources下新建logback-spring.xml

2.多环境日志级别处理:

3.日志文件路径处理

4.通过application.properties文件对Logback进行配置

5.每个环境单独设置日志文件路径

6.使用方法及结果:



可以看到日志输出了,同时file文件也相应的生成。此处我设置的log级别是info 所以dubug没有显示。
总结:
通过这篇文章,我们实现多环境下的日志级别以及file输出目录的设置。希望能帮助有多环境日志配置需求的同学们。
网友评论