<?xml version="1.0" encoding="utf-8"?> <log4net xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender"> <param name="File" value="Logs/" /> <param name="AppendToFile" value="True" /> <param name="MaxSizeRollBackups" value="10" /> <param name="StaticLogFileName" value="false" /> <param name="DatePattern" value="yyyy-MM-dd".log"" /> <param name="RollingStyle" value="Date" /> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="# %date{HH:mm:ss} [%thread] %-5level %logger # %message%newline" /> </layout> </appender> <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender"> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" /> </layout> </appender> <root> <!-- OFF < FATAL < ERROR < WARN < INFO < DEBUG < ALL --> <level value="WARN" /> <appender-ref ref="RollingLogFileAppender" /> <appender-ref ref="ConsoleAppender" /> </root> </log4net>
log4net 输出日志至控制台和文件并按天分割
未经允许不得转载:码农很忙 » log4net 输出日志至控制台和文件并按天分割