bl双性强迫侵犯h_国产在线观看人成激情视频_蜜芽188_被诱拐的少孩全彩啪啪漫画

SpringBoot中slf4j日志依賴關系

Spring Boot中slf4j日志依賴關系?相信很多沒有經驗的人對此束手無策,為此本文總結了問題出現的原因和解決方法,通過這篇文章希望你能解決這個問題。

成都創新互聯公司從2013年成立,是專業互聯網技術服務公司,擁有項目成都網站設計、做網站網站策劃,項目實施與項目整合能力。我們以讓每一個夢想脫穎而出為使命,1280元靖西做網站,已為上家服務,為靖西各地企業和個人服務,聯系電話:18982081108

底層依賴關系

Spring Boot中slf4j日志依賴關系

關系如何轉化

Spring Boot中slf4j日志依賴關系

底層通過偷梁換柱的方法,用jcl、jul、log4j中間轉換包進行轉化

Spring Boot中slf4j日志依賴關系

如果要引入其他框架,必須將其中默認日志依賴剔除

SpringBoot從maven依賴中剔除springframework:spring-core中的common-logging

<dependency>
 <groupId>org.springframework</groupId>
 <artifactId>spring-core</artifactId>
 <version>4.3.20.RELEASE</version>
 <exclusions>
 <exclusion>
  <artifactId>commons-logging</artifactId>
  <groupId>commons-logging</groupId>
 </exclusion>
 </exclusions>
</dependency>

SpringBoot默認日志級別為INFO級別

日志優先級從小到大順序為:

trace<debug<info<warn<error

package com.example.demo;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

@RunWith(SpringRunner.class)
@SpringBootTest
public class DemoApplicationTests {

 Logger log = LoggerFactory.getLogger(getClass());

 @Test
 public void contextLoads() {
  log.trace("trace日志");
  log.debug("debug日志");
  log.info("info日志");
  log.warn("warn日志");
  log.error("error日志");
 }

}

啟動運行,控制臺打印只打印了info及以上級別

2018-11-09 00:13:36.899  INFO 8156 --- [main] com.example.demo.DemoApplicationTests    : info日志
2018-11-09 00:13:36.900  WARN 8156 --- [main] com.example.demo.DemoApplicationTests    : warn日志
2018-11-09 00:13:36.900 ERROR 8156 --- [main] com.example.demo.DemoApplicationTests    : error日志

日志基礎配置

# 指定日志輸入級別
logging.level.com.example.demo=trace 

# 指定日志輸出位置和日志文件名
logging.file=./log/log.txt

# 指定日志輸出路徑,若file和path同時配置,則file生效
# 此配置默認生成文件為spring.log
#logging.path=./log

# 控制臺日志輸出格式
# -5表示從左顯示5個字符寬度
logging.pattern.console=%d{yyyy-MM-dd HH:mm:ss.SSS} %highlight(%-5level) %boldYellow(%thread) | %boldGreen(%logger) | %msg%n

# 文件中輸出的格式
logging.pattern.file=%d{yyyy-MM-dd HH:mm:ss.SSS} = [%thread] = %-5level = %logger{50} - %msg%n

看完上述內容,你們掌握Spring Boot中slf4j日志依賴關系的方法了嗎?如果還想學到更多技能或想了解更多相關內容,歡迎關注創新互聯行業資訊頻道,感謝各位的閱讀!

網站標題:SpringBoot中slf4j日志依賴關系
文章位置:http://vcdvsql.cn/article36/gghesg.html

成都網站建設公司_創新互聯,為您提供自適應網站網站收錄外貿網站建設GoogleApp設計

廣告

聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯

網站托管運營