Log4net.config 配置
<?xml version="1.0" encoding="utf-8" ?> <configuration> <!-- This section contains the log4net configuration settings --> <log4net> <appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender"> <!--日志文件路径--> <file value="Log/" /> <!--是否是向文件中追加日志--> <appendToFile value="true" /> <rollingStyle value="Composite" /> <!--日志文件名是否是固定不变的--> <staticLogFileName value="false" /> <!--日志文件名格式为:20200220.log--> <datePattern value="yyyyMMdd'.log'" /> <!--log保留天数--> <maxSizeRollBackups value="10" /> <!--最大文件大小--> <maximumFileSize value="20MB" /> <!--信息日志布局--> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%date [%thread] %-5level %message%newline" /> </layout> </appender> <!-- Setup the root category, add the appenders and set the default level --> <root> <level value="ALL" /> <appender-ref ref="RollingLogFileAppender" /> </root> </log4net> </configuration>