迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
http://www.csharpwin.com/csharpspace/678.shtml 1.下载log4net (Google log4net)
实际使用:
<?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <section name="log4net" type="System.Configuration.IgnoreSectionHandler"/> </configSections> <appSettings> </appSettings> <log4net> <appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender"> <file value="DMHJPGRKLog.log" /> 文件名 <appendToFile value="true" /> <rollingStyle value="Size" /> <maxSizeRollBackups value="3" /> <maximumFileSize value="30MB" /> <staticLogFileName value="true" /> <datePattern value="yyyyMMdd-HH:mm:ss" /> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%date[TID:%-5thread][%level][%logger] %message%newline" /> </layout> </appender> <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender"> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" /> </layout> </appender> <root> <level value="ALL" /> <appender-ref ref="LogFileAppender" /> <appender-ref ref="ConsoleAppender" /> </root> </log4net> </configuration>
AssemblyInfo.cs
// 将log4net添加到本工程 [assembly: log4net.Config.XmlConfigurator(ConfigFile = "RK.config", Watch = true)]
//调用------------------------------------------------------------
|
请发表评论