< configSections >
< section name = "log4net" type = "log4net.Config.Log4NetconfigurationSectionhandler, log4net" />
</ configSections >
< log4net >
< logger name = "SysRFLogger" >
< level value = "DEBUG" />
< appender-ref ref = "SysRFAppender" />
</ logger >
< logger name = "DebugRFLogger" >
< level value = "DEBUG" />
< appender-ref ref = "DebugAppender" />
</ logger >
< logger name = "MsgLogger" >
< level value = "DEBUG" />
< appender-ref ref = "MsgAppender" />
</ logger >
< logger name = "OperInfoLogger" >
< level value = "DEBUG" />
< appender-ref ref = "OperInfoAppender" />
</ logger >
< appender name = "SysRFAppender" type = "log4net.Appender.RollingFileAppender" >
< file value = "Logs\syslog.log" />
< appendToFile value = "true" />
< rollingStyle value = "Date" />
< preserveLogFileNameExtension value = "true" />
< datePattern value = "yyyyMMdd" />
< layout type = "log4net.Layout.PatternLayout" >
< conversionpattern value = "%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
</ layout >
</ appender >
< appender name = "DebugAppender" type = "log4net.Appender.RollingFileAppender" >
< file value = "Logs\sysDebuglog.log" />
< appendToFile value = "true" />
< rollingStyle value = "Date" />
< preserveLogFileNameExtension value = "true" />
< datePattern value = "yyyyMMdd" />
< layout type = "log4net.Layout.PatternLayout" >
< conversionPattern value = "%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
</ layout >
</ appender >
< appender name = "MsgAppender" type = "log4net.Appender.RollingFileAppender" >
< file value = "Logs\Messagelog.log" />
< appendToFile value = "true" />
< rollingStyle value = "Date" />
< preserveLogFileNameExtension value = "true" />
< datePattern value = "yyyyMMdd" />
< layout type = "log4net.Layout.PatternLayout" >
< conversionPattern value = "%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
</ layout >
</ appender >
< appender name = "OperInfoAppender" type = "log4net.Appender.AdoNetAppender" >
< bufferSize value = "1" />
< connectionType value = "System.Data.sqlClient.SqlConnection, System.Data, Version=4.0.30319.18020, Culture=neutral, publickeytoken=b77a5c561934e089" />
< commandText value = "INSERT INTO LOG_USEROPERLOG ([ID],[Date],[User],[Flag],[OperInfo],[OperFlag],[OperResult],[Message]) VALUES (@Id,@log_date, @user, @flag, @operinfo,@operflag, @operresult, @message)" />
< parameter >
< parameterName value = "@Id" />
< dbType value = "String" />
< size value = "36" />
< layout type = "NT.MultithreadingTaskService.Log.Layout.UserOperLayOut,NT.MultithreadingTaskService.Log" >
< param name = "ConversionPattern" value = "%property{ID}" />
</ layout >
</ parameter >
< parameter >
< parameterName value = "@log_date" />
< dbType value = "DateTime" />
< layout type = "log4net.Layout.RawTimeStampLayout" />
</ parameter >
< parameter >
< parameterName value = "@user" />
< dbType value = "String" />
< size value = "64" />
< layout type = "NT.MultithreadingTaskService.Log.Layout.UserOperLayOut,NT.MultithreadingTaskService.Log" >
< param name = "ConversionPattern" value = "%property{User}" />
</ layout >
</ parameter >
< parameter >
< parameterName value = "@flag" />
< dbType value = "Int32" />
< layout type = "NT.MultithreadingTaskService.Log.Layout.UserOperLayOut,NT.MultithreadingTaskService.Log" >
< param name = "ConversionPattern" value = "%property{Flag}" />
</ layout >
</ parameter >
< parameter >
< parameterName value = "@operinfo" />
< dbType value = "String" />
< size value = "255" />
< layout type = "NT.MultithreadingTaskService.Log.Layout.UserOperLayOut,NT.MultithreadingTaskService.Log" >
< param name = "ConversionPattern" value = "%property{OperInfo}" />
</ layout >
</ parameter >
< parameter >
< parameterName value = "@operflag" />
< dbType value = "String" />
< size value = "32" />
< layout type = "NT.MultithreadingTaskService.Log.Layout.UserOperLayOut,NT.MultithreadingTaskService.Log" >
< param name = "ConversionPattern" value = "%property{OperFlag}" />
</ layout >
</ parameter >
< parameter >
< parameterName value = "@operresult" />
< dbType value = "String" />
< size value = "255" />
< layout type = "NT.MultithreadingTaskService.Log.Layout.UserOperLayOut,NT.MultithreadingTaskService.Log" >
< param name = "ConversionPattern" value = "%property{OperResult}" />
</ layout >
</ parameter >
< parameter >
< parameterName value = "@message" />
< dbType value = "String" />
< size value = "4000" />
< layout type = "NT.MultithreadingTaskService.Log.Layout.UserOperLayOut,NT.MultithreadingTaskService.Log" >
< param name = "ConversionPattern" value = "%property{Message}" />
</ layout >
</ parameter >
</ appender >
< root >
< level value = "DEBUG" />
< appender-ref ref = "SysRFAppender" />
</ root >
</ log4net >
第三步:打开项目assemblyinfo.cs文件(UI层)
加入:[assembly: log4net.Config.XmlConfigurator(ConfigFile = "web.config", Watch = true)]
|