logback 設定不同包下的日誌級別

2021-10-07 06:45:11 字數 2027 閱讀 8711

1、實現效果:專案的整體的日誌列印級別為error,但在某個包下或某個類想列印info級別的日誌。

2、配置:

file是error級別日誌列印;

special 是info級別日誌列印;

file與special唯一不同是日誌儲存路徑不同,其它策略相同;

通過 logger標籤指定包路徑或類路徑並引用special;

<

?xml version=

"1.0" encoding=

"utf-8"

?>

test<

/contextname>

"file"

class

=>

="ch.qos.logback.core.rolling.timebasedrollingpolicy"

>

$/logs/test/test.%d.%i.log<

/filenamepattern>

30<

/maxhistory>

="ch.qos.logback.core.rolling.sizeandtimebasedfnatp"

>

10mb<

/maxfilesize>

<

/timebasedfilenamingandtriggeringpolicy>

<

/rollingpolicy>

%d %p (

%file:

%line\)

-%m%n -[%x

,%x]<

/pattern>

utf-

8<

/charset>

<

/encoder>

<

"special"

class

=>

="ch.qos.logback.core.rolling.timebasedrollingpolicy"

>

$/logs/test/special/special.%d.%i.log<

/filenamepattern>

30<

/maxhistory>

="ch.qos.logback.core.rolling.sizeandtimebasedfnatp"

>

10mb<

/maxfilesize>

<

/timebasedfilenamingandtriggeringpolicy>

<

/rollingpolicy>

%d %p (

%file:

%line\)

-%m%n -[%x

,%x]<

/pattern>

utf-

8<

/charset>

<

/encoder>

<

"stdout"

class

=>

%d %p (

%file:

%line\)

-%m%n <

/pattern>

utf-

8<

/charset>

<

/encoder>

<

<

!--列印sql--

>

"daolog" level=

"error"

/>

<

!-- 記錄special操作日誌 --

>

"aaa.bbb.ccc.demoservice" level=

"info"

>

"special"

/>

<

/logger>

"error"

>

"file"

/>

"stdout"

/>

<

/root>

<

/configuration>

為不同專案設定不同的git賬號

安裝git的時候,按照網上的教程安裝完成後,就設定了全域性的git使用者,就是說所有的git專案都會使用這個使用者名稱和郵箱,如下設定的 git config global user.name username git config global user.email useremail 可以使用g...

如何為不同頁面設定不同的title

abcd 這部分 一般放在layout file中。其結果是所有的頁面都使用相同的title,這樣不利於別人檢索到你的網頁。那麼如何在不同的頁面顯示不同的title呢?一.content for title do recent episodes end 然後在layout中 asciicasts y...

pytorch 實現模型不同層設定不同的學習率方式

在目標檢測的模型訓練中,我們通常都會有乙個特徵提取網路backbone,例如yolo使用的darknet ssd使用的vgg 16。為了達到程式設計客棧比較好的訓練效果,往往會載入預訓練的backbone模型引數,然後在此基礎上訓練檢測網路,並對backbone進行微調,這時候就需要為backbon...