C# - Log4Net configuration example
less than 1 minute read
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<? xml version = "1.0" encoding = "utf-8" ?>
< configuration >
< configSections >
<!-- Level 1 -->
< section name = "log4net"
type = "log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
<!-- Level 2 -->
</ configSections >
< log4net >
< appender name = "RollingFileAppender" type = "log4net.Appender.RollingFileAppender" >
< file value = "App_DebugLog.txt" />
< appendToFile value = "true" />
< rollingStyle value = "Size" />
< maxSizeRollBackups value = "5" />
< maximumFileSize value = "10MB" />
< staticLogFileName value = "true" />
< filter type = "log4net.Filter.LevelRangeFilter" >
< levelMin value = "INFO" />
< levelMax value = "FATAL" />
</ filter >
< layout type = "log4net.Layout.PatternLayout" >
< conversionPattern value = "[%date{ISO8601}] [%thread] %level - %message, %exception%newline" />
</ layout >
</ appender >
< appender name = "ConsoleAppender" type = "log4net.Appender.ConsoleAppender" >
< layout type = "log4net.Layout.PatternLayout" >
< conversionPattern value = "[%date{ISO8601}] [%thread] %level - %message, %exception%newline%newline" />
</ layout >
< filter type = "log4net.Filter.LevelRangeFilter" >
< levelMin value = "INFO" />
< levelMax value = "FATAL" />
</ filter >
</ appender >
< root >
< level value = "ALL" />
< appender - ref ref = "RollingFileAppender" />
< appender - ref ref = "ConsoleAppender" />
</ root >
</ log4net >
</ configuration >