Log4net配置检查点
作者:互联网
-
有引用log4net.dll
-
有配置文件,Web.config或log4net.config
-
有section节
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"> <configSections> <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/> <sectionGroup name="system.web"> <section name="logService" type="OilDigital.CGGL.BLL.LogServiceSection, OilDigital.CGGL.BLL.Common" allowDefinition="MachineToApplication" restartOnExternalChanges="true"/>
有system.web节,同时确保logProviderWithLog4Net中的enabled为true
<system.web> <logService defaultProvider="logProviderWithLog4Net"> <providers> <add name="logProviderWithLog4Net" type="OilDigital.CGGL.BLL.Log.LogProviderWithLog4Net,OilDigital.CGGL.BLL.Log" enabled="true" loggingUserName="false" loggerName="OperationLogger"/> </providers> </logService>
有log4net节
<log4net> <appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender"> <file value="Logs\\opeartions-"/> <appendToFile value="true"/> <rollingStyle value="Date"/> <datePattern value="yyyy-MM-dd".log""/> <maximumFileSize value="10MB"/> <staticLogFileName value="false"/> <lockingModel type="log4net.Appender.FileAppender+MinimalLock"/> <layout type="log4net.Layout.PatternLayout"> <param name="ConversionPattern" value="%d [%t] %-5p %c %m%n"/> </layout> </appender> <logger name="OperationLogger"> <level value="INFO"/> <appender-ref ref="LogFileAppender"/> </logger> </log4net>
-
Global.asax的Application_Start方法中有初始化
//初始化log4net对象 log4net.Config.XmlConfigurator.Configure();
标签:Log4net,log4net,Web,配置文件,初始化,配置,检查点,config 来源: https://www.cnblogs.com/Sabre/p/15226058.html