欢迎光临
我们一直在努力

log4net 输出日志至控制台和文件并按天分割

<?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&quot;.log&quot;" />
    <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>
赞(1) 打赏
未经允许不得转载:码农很忙 » log4net 输出日志至控制台和文件并按天分割

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏