<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />
<section name="businessLog" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />
</configSections>
<log4net>
<!--定义输出到文件中-->
<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
<!--日志的路径-->
<file value="./Log/log" />
<!--是否覆盖,默认是追加true-->
<appendToFile value="true"/>
<!--滚动类型-->
<param name="RollingStyle" value="Date"/>
<!--文件名称-->
<DatePattern value="-yyyy-MM-dd".log"" />
<!--设置无限备份=-1-->
<maxSizeRollBackups value="-1"/>
<!--滚动规则:Composite为混合模式,本例中将以日期维度和文件大小的维度生成日志文件(即若单个文件大小达到了100MB会备份当前文件到历史并生成新的文件;若日期为第二天也会备份并生成新的文件)-->
<rollingStyle value="Composite" />
<!--这个保证在日志分割时,新日志的序号会添加在后缀名之前-->
<preserveLogFileNameExtension value="true"/>
<!--每个文件的最大10KB-->
<maximumFileSize value="100MB"/>
<!--名称是否可以更改为false为可以更改-->
<param name="StaticLogFileName" value="false" />
<!--文件锁定模式-->
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<layout type="log4net.Layout.PatternLayout">
<!--每条日志末尾的文字说明-->
<footer value="
" />
<!--输出格式-->
<conversionPattern value="%date %-5level %logger %message%newline" />
</layout>
</appender>
<!--缓存一定数量再写入到日志-->
<!--<appender name="BufferingForwardingAppender" type="log4net.Appender.BufferingForwardingAppender">
<bufferSize value="10" />
<appender-ref ref="RollingFileAppender" />
</appender>-->
<!--定义输出到邮件中-->
<!--<appender name="SmtpAppender" type="log4net.Appender.SmtpAppender,log4net">
<authentication value="Basic"/>
<to value="me@tecyang.com" />
<from value="log@tecyang.com" />
<username value="log@tecyang.com" />
<password value="" />
<subject value="dsc logging message" />
<smtpHost value="smtp.exmail.qq.com" />
<bufferSize value="5" />
<lossy value="true" />
<evaluator type="log4net.Core.LevelEvaluator,log4net">
<threshold value="Error" />
</evaluator>
<layout type="log4net.Layout.PatternLayout,log4net">
<conversionPattern value="%property{log4net:HostName} :: %level :: %message %newlineLogger: %logger%newlineThread: %thread%newlineDate: %date%newlineNDC: %property{NDC}%newline%newline" />
</layout>
</appender>-->
<!--定义输出到Access数据库中-->
<!--<appender name="AccessAppender" type="log4net.Appender.AdoNetAppender">
<bufferSize value="1" />
<connectionString value="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\Log\Log.mdb;User Id=;Password=;" />
<commandText value="INSERT INTO Log ([Date],[Thread],[Level],[Logger],[Message],[Exception]) VALUES (@log_date, @thread, @log_level, @logger, @message, @exception)" />
<parameter>
<parameterName value="@log_date" />
<dbType value="String" />
<size value="255" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date" />
</layout>
</parameter>
<parameter>
<parameterName value="@thread" />
<dbType value="String" />
<size value="255" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%thread" />
</layout>
</parameter>
<parameter>
<parameterName value="@log_level" />
<dbType value="String" />
<size value="50" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%level" />
</layout>
</parameter>
<parameter>
<parameterName value="@logger" />
<dbType value="String" />
<size value="255" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%logger" />
</layout>
</parameter>
<parameter>
<parameterName value="@message" />
<dbType value="String" />
<size value="1024" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%message" />
</layout>
</parameter>
<parameter>
<parameterName value="@exception" />
<dbType value="String" />
<size value="2000" />
<layout type="log4net.Layout.ExceptionLayout" />
</parameter>
</appender>-->
<!--定义日志的输出媒介。-->
<root>
<!-- Levels: ALL, DEBUG, INFO, WARN, ERROR, FATAL, OFF -->
<level value="ERROR,INFO,DEBUG" />
<!--文件形式记录日志-->
<appender-ref ref="RollingFileAppender" />
<!--邮件发送日志-->
<!--<appender-ref ref="SmtpAppender" />-->
<!--Access数据库记录日志
<appender-ref ref="AccessAppender" />-->
</root>
</log4net>
<!--业务日志-->
<businessLog>
<!--定义输出到文件中-->
<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
<!--日志的路径-->
<file value="./Log/businessLog" />
<!--是否覆盖,默认是追加true-->
<appendToFile value="true"/>
<!--滚动类型-->
<param name="RollingStyle" value="Date"/>
<!--文件名称-->
<DatePattern value="-yyyy-MM-dd".log"" />
<!--设置无限备份=-1-->
<maxSizeRollBackups value="-1"/>
<!--每个文件的最大10KB-->
<maximumFileSize value="1024KB"/>
<!--名称是否可以更改为false为可以更改-->
<param name="StaticLogFileName" value="false" />
<!--文件锁定模式-->
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<layout type="log4net.Layout.PatternLayout">
<!--每条日志末尾的文字说明-->
<footer value="
" />
<!--输出格式-->
<conversionPattern value="%date %-5level %logger %message%newline" />
</layout>
</appender>
<!--定义日志的输出媒介。-->
<root>
<!-- Levels: ALL, DEBUG, INFO, WARN, ERROR, FATAL, OFF -->
<level value="ERROR,INFO,DEBUG" />
<!--文件形式记录日志-->
<appender-ref ref="RollingFileAppender" />
<!--邮件发送日志-->
<!--<appender-ref ref="SmtpAppender" />-->
<!--Access数据库记录日志
<appender-ref ref="AccessAppender" />-->
</root>
</businessLog>
</configuration>