-
有引用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();
相关文章
- 10-31IDEA & MAVEN配置代理
- 10-31Sublime 配置代理以及 Socks5 转 http 代理
- 10-31spring-boot 2.5.4,nacos 作为配置、服务发现中心,Cloud Native Buildpacks 打包镜像,GitLab CI/CD
- 10-31nginx搭建遇到的配置问题(持续更新)
- 10-31Termux 高级终端安装使用配置教程
- 10-31Mac上配置GTK环境
- 10-31树莓派3 selenium 配置
- 10-31Django学习day2——Django安装与环境配置
- 10-31跟着医生学kivy:kivy的基础工作,配置稳定正确的编译环境
- 10-31Visual Studio 配置 winmerge