springboot更换日志系统

背景:springboot.2.1.2默认使用logback作为日志系统,我想禁用logback,换成效率更高的log4j2。

一、去除默认的logback依赖

1. 方法一

精准去除

dependencies {
  // https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web
  compile (group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '2.1.2.RELEASE'){
  exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging'
  }
  testCompile group: 'junit', name: 'junit', version: '4.12'
}

2. 方法二

通过全局配置入口

configurations {
  // remove default logger
  all*.exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging'  //IntelliJ会WARNING,忽略这个警告
}

 

二、添加log4j2的日志系统

在dependencies {}中添加依赖即可。

compile group: 'org.springframework.boot', name: 'spring-boot-starter-log4j2', version: '2.1.2.RELEASE'

三、指定配置文件

在application.yaml中设置配置文件路径

logging:
  config: classpath:log4j2.xml

 

转载于:https://www.cnblogs.com/yoyotl/p/10458436.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值