gradle + SpringBoot + Log4j 配置

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

基本方法就是將compile范圍依賴(lài)的spring-boot-starter-logging排除,然后依賴(lài)spring-boot-starter-log4j即可

build.gradle中配置如下

configurations {    
    compile.exclude module: 'spring-boot-starter-logging'//排除對(duì)默認(rèn)logging的依賴(lài)
}

dependencies {    
    testCompile group: 'junit', name: 'junit', version: '4.12' 
    compile("org.springframework.boot:spring-boot-starter-web:1.4.0.RELEASE")  
    //添加對(duì)log4j starter的依賴(lài)。
    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'
    }
    //添加對(duì)log4j starter的依賴(lài)。
    compile("org.springframework.boot:spring-boot-starter-log4j:1.3.7.RELEASE") 
}
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

推薦閱讀更多精彩內(nèi)容