SpringBoot中怎么實(shí)現(xiàn)一個(gè)slf4j日志功能,針對(duì)這個(gè)問(wèn)題,這篇文章詳細(xì)介紹了相對(duì)應(yīng)的分析和解答,希望可以幫助更多想解決這個(gè)問(wèn)題的小伙伴找到更簡(jiǎn)單易行的方法。
其pom.xml里的依賴(lài)定義如下:
上圖看到很多Starter,比如Spring-boot-starter-data-redis, Spring-boot-starter-web等等。這些Starter都包含了一個(gè)spring-boot-starter, 而這個(gè)starter又包含了一個(gè)實(shí)現(xiàn)logging的starter,叫做spring-boot-starter-logging.
也就是說(shuō),如果我們使用SpringBoot,無(wú)需再導(dǎo)入額外的配置,就能使用日志功能了。
SpringBoot slf4j的默認(rèn)實(shí)現(xiàn)是logback,默認(rèn)輸出是到控制臺(tái)console:
As you can see the default logging framework is Logback with SLF4j as implementation.
By default, all logging goes to console.
在Application.properties文件里使用logging.level.root配置項(xiàng)目全局的日志級(jí)別:
當(dāng)然要針對(duì)個(gè)別包進(jìn)行日志級(jí)別的分別配置也是可以的:
logging.level.some.package.path=DEBUG
logging.level.some.other.package.path=ERROR
Custom configuration using logback.xml
Spring Boot will pick up all custom configuration using logback.xml as long as it is in the application class path.
將日志寫(xiě)入本地日志文件的做法:
關(guān)于SpringBoot中怎么實(shí)現(xiàn)一個(gè)slf4j日志功能問(wèn)題的解答就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,如果你還有很多疑惑沒(méi)有解開(kāi),可以關(guān)注創(chuàng)新互聯(lián)-成都網(wǎng)站建設(shè)公司行業(yè)資訊頻道了解更多相關(guān)知識(shí)。
網(wǎng)站題目:SpringBoot中怎么實(shí)現(xiàn)一個(gè)slf4j日志功能-創(chuàng)新互聯(lián)
文章地址:http://www.chinadenli.net/article2/dcsiic.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站建設(shè)、自適應(yīng)網(wǎng)站、移動(dòng)網(wǎng)站建設(shè)、微信小程序、外貿(mào)網(wǎng)站建設(shè)、App設(shè)計(jì)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀(guān)點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話(huà):028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容