Use of log4net and log4net

Source: Internet
Author: User

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

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.