gradle + SpringBoot + Log4j 配置

本文中所述SpringBoot基于1.4.0.RELEASE版本

基本方法就是将compile范围依赖的spring-boot-starter-logging排除,然后依赖spring-boot-starter-log4j即可

build.gradle中配置如下

configurations {    
    compile.exclude module: 'spring-boot-starter-logging'//排除对默认logging的依赖
}

dependencies {    
    testCompile group: 'junit', name: 'junit', version: '4.12' 
    compile("org.springframework.boot:spring-boot-starter-web:1.4.0.RELEASE")  
    //添加对log4j starter的依赖。
    compile("org.springframework.boot:spring-boot-starter-log4j:1.3.7.RELEASE") 
}

或者

dependencies {    
    testCompile group: 'junit', name: 'junit', version: '4.12' 
    compile("org.springframework.boot:spring-boot-starter-web:1.4.0.RELEASE")   {
        exclude module:'spring-boot-starter-logging'
    }
    //添加对log4j starter的依赖。
    compile("org.springframework.boot:spring-boot-starter-log4j:1.3.7.RELEASE") 
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容