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
  • 相关阅读:
    linux文件种类及其扩展名
    路由器终端常用linux命令汇总(持续更新)
    初识Makefile
    volatile关键字作用
    无言
    coredump文件抓取设置
    connect设置连接超时
    unix socket服务器
    交叉编译工具链制作
    编译选项说明
  • 原文地址:https://www.cnblogs.com/yoyotl/p/10458436.html
Copyright © 2011-2022 走看看