通常對控制檯輸入的日誌咱們使用的 Appender 爲 ConsoleAppender ,日誌爲白色文字。app
當咱們想到 DEBUG,INFO,WARN,ERROR 每種日誌設置一種顏色時咱們須要將 Appender 改成 ColoredConsoleAppender spa
而後增長相應的顏色配置日誌
<appender name="ConsoleAppender" type="log4net.Appender.ColoredConsoleAppender"> <mapping> <level value="ERROR" /> <foreColor value="Red, HighIntensity" /> </mapping> <mapping> <level value="Warn" /> <foreColor value="Yellow,HighIntensity" /> </mapping> <mapping> <level value="Info" /> <foreColor value="White" /> </mapping> <mapping> <level value="Debug" /> <foreColor value="Purple, HighIntensity" /> </mapping> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%date [%thread] %-5level %logger - %message%newline" /> </layout> </appender>
顏色的值能夠爲code
Blue
Green
Red
White
Yellow
Purple
Cyan
HighIntensity