SpringBoot2 x切換日誌框架為

2021-10-11 07:48:45 字數 1286 閱讀 9488

目錄

springboot2.x整合log4j

文章目錄

springboot:底層是spring框架,spring框架預設是用jcl(commons-logging);『springboot選用 slf4j和logback;

開發的時候,日誌記錄方法的呼叫,不應該來直接呼叫日誌的實現類,而是呼叫日誌抽象層裡面的方法;給系統裡面匯入slf4j的jar和 logback的實現jar

import org.slf4j.logger;

import org.slf4j.logge***ctory;

public class helloworld

}

org.springframework.boot

spring-boot-starter-log4j

1.3.8.release

org.springframework.boot

spring-boot-starter-web

logback-classic

ch.qos.logback

log4j-over-slf4j

org.slf4j

# log4j配置

log4j.rootcategory=info, stdout, file

# 控制台輸出

# root日誌輸出到檔案

# 按不同package進行輸出

# com.micai包下的日誌配置

log4j.category.com.micai=debug, didifile

# com.micai下的日誌輸出

# error級別輸出到特定的日誌檔案中

log4j.logger.error=errorfile

# error日誌輸出

排除 springboot 預設的 logback 依賴
org.springframework.boot

spring-boot-starter-web

spring-boot-starter-logging

org.springframework.boot

新增log4j的依賴

org.springframework.boot

spring-boot-starter-log4j2

基於SpringBoot 2 X整合Druid

說明 本文旨在整理springboot 2.x整合druid基礎功能,如有問題請指出 參考資料 基於springboot 2.x版本,這裡是引入druid spring boot2 starter的方式來配置,所以不需要不需要configbean來配置druid,如果引入的是druid,則需要con...

SpringBoot2 x 整合Druid詳細步驟

druid spring boot starter模式 這種方式比較簡單,不需要自己寫配置類。在匯入依賴以及配置好配置檔案yml即可。pom.xml com.alibaba druid spring boot starter 1.1.10 spring datasource url jdbc mys...

springboot2 x基礎 整合redis

在springboot中一般使用redistemplate提供的方法來操作redis。那麼使用springboot整合redis 需要那些步驟呢。環境安裝 任選 centos7 搭建redis 5單機服務 centos7 搭建 redis 5 cluster 集群服務 在專案中新增 spring b...