标签:
<?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" /> </configSections> <log4net> <appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender"> <file value="Log\log.txt" /> <appendToFile value="true" /> <maxSizeRollBackups value="10" /> <maximumFileSize value="1024KB" /> <rollingStyle value="Size" /> <staticLogFileName value="true" /> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%date [%thread] %-5level %logger - %message%newline" /> </layout> </appender> <root> <!-- OFF FATAL ERROR WARN INFO DEBUG ALL --> <level value="ALL" /> <appender-ref ref="RollingLogFileAppender" /> </root> </log4net> </configuration> // 从配置文件读取 log4net 配置 log4net.Config.XmlConfigurator.Configure(); ILog logWriter = log4net.LogManager.GetLogger("Form1"); logWriter.Info("User Click!");
标签:
原文地址:http://www.cnblogs.com/z5337/p/5414958.html