zoukankan      html  css  js  c++  java
  • 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
  • 相关阅读:
    初赛—算法复杂度
    2-SAT
    最小生成树
    18-短信验证码接口
    17-腾讯云短信开发
    16-手机号是否存在验证接口
    15-多方式登录
    14-登录注册页面
    13-Git
    12-跨域请求详解
  • 原文地址:https://www.cnblogs.com/yoyotl/p/10458436.html
Copyright © 2011-2022 走看看