Use of log4net and log4net
1.0 download and reference log4net. dll2.0 modify Web. config 1 <configuration> 2 <configSections> 3 <section name = "log4net" type = "log4net. config. log4NetConfigurationSectionHandler, log4net "/> 4 </configSections> 5 6 <log4net> 7 <! -- Error Log configuration: The name can be defined by the programmer, however, this name must be consistent with the ref value in 8 <appender-ref = "ErrorAppender"/> in <logger name = "logerror"> 9 --> 10 <appender name = "ErrorAppender" type = "log4net. appender. rollingFileAppender "> 11 <! -- The location of Log File storage is: Log \ LogError \ --> 12 <param name = "File" value = "Log \ LogError \"/> 13 <! -- Indicates that the content is appended and saved to the log file --> 14 <param name = "AppendToFile" value = "true"/> 15 <! -- 100 log backups per day --> 16 <param name = "MaxSizeRollBackups" value = "100"/> 17 <! -- Indicates that the size of each log file can only be 10 MB --> 18 <param name = "MaxFileSize" value = "10240"/> 19 <! -- The file name is in a fixed format --> 20 <param name = "StaticLogFileName" value = "false"/> 21 <! -- The file name is in a fixed format: yyyyMMdd --> 22 <param name = "DatePattern" value = "yyyy-MM-dd & quot;. log & quot;"/> 23 <! -- Every day, the file is named by yyyyMMdd --> 24 <param name = "RollingStyle" value = "Date"/> 25 <! -- Set the log format to write --> 26 <layout type = "log4net. layout. patternLayout "> 27 <param name =" ConversionPattern "value =" % n exception time: % d [% t] % n exception level: %-5 p % n exception class: % c [% x] % n % m % n "/> 28 </layout> 29 </appender> 30 <! -- Log4net. LogManager. GetLogger ("logerror") use this to select this type --> 31 <logger name = "logerror"> 32 <! -- If this configuration file is set to ALL, it indicates that information logs (Info) 2, warning logs (Warn) 3, Error logs (Error) --> 33 <! -- <Level value = "Error"/> only logs of the Error level are recorded --> 34 <level value = "ALL"/> 35 <appender-ref = "ErrorAppender "/> 36 </logger> 37 38 </log4net> 39 <system. web> 40 <compilation debug = "true" targetFramework = "4.5"/> 41