Spring Boot日志定义

Spring Boot 日志格式自定义

  1. 配置项 logging.file 指定日志文件名称
  2. 配置项 logging.path 指定日志目录(此时的日志名称为spring.log)
  3. 日志文件输出,文件的默认大小为10M,超过会自动分隔
  4. logging.pattern.console 配置控制台输出日志格式
  5. logging.pattern.file 配置文件日志输出格式

Spring Boot 默认使用LogBack作为日志框架

也就是说,只需要在classpath中添加一个 logback.xml 或者logback-spring.xml 文件,就可以自定义日志的输出

Spring Boot 使用其他日志的不走

  1. pom.xml中排除默认日志框架依赖
  2. 加入新的日志框架依赖
  3. 添加相应的日志配置文件到classpath中

猜你喜欢

转载自blog.csdn.net/afgasdg/article/details/79758633