springboot系列学习笔记全部文章请移步值博主专栏**: spring boot 2.X/spring cloud Greenwich。
由于是一系列文章,所以后面的文章可能会使用到前面文章的项目。springboot系列代码全部上传至GitHub:https://github.com/liubenlong/springboot2_demo
本系列环境:Java11;springboot 2.1.1.RELEASE;springcloud Greenwich.RELEASE;MySQL 8.0.5;
单元测试和日志比较简单,放到一起讲一下。本篇文章需要使用到Junit、TestNg、Mockito、Spring Testing,本文不会对其使用进行特别详细的说明,请自行检索
日志
springboot官方文档中指出,如果我们使用Starters
,那么默认使用Logback
作为日志输出组件。当然还支持Commons Logging, Log4J等组件。
简单日志配置(包含了指定文件目录, 格式,以及level):
logging:
level:
root: info
com.example.controller: info
com.example.service: warn
file: d://a.log
pattern:
console: "%d - %msg%n"