在log4net中将日志信息附加到文件名中

时间:2019-06-24 09:02:53

标签: c# log4net

创建后,我想在日志文件名称中附加日志信息。例如INFO 2019-01-01.txt和ERROR 2019-01-01.txt

<configSections>
    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
  </configSections>
  <log4net>
    <root>
      <level value="ALL" />
      <appender-ref ref="FileAppender" />
    </root>
    <appender name="FileAppender" type="log4net.Appender.FileAppender">
      <file type="log4net.Util.PatternString" value="App_Data\Logs\%property{LogName}%utcdate{yyyy-MM-dd}.txt"/><!--TraceLog.%property{log4net:HostName}.txt-->
      <appendToFile value="true" />
      <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date %level %logger - %message%newline" />
      </layout>
    </appender>
  </log4net>

0 个答案:

没有答案