Log4Net stops logging, how to recover?

雨燕双飞 提交于 2019-12-24 11:14:13

问题


I have an issue with log4net (c#, WinForms) where it stops logging if there is a momentary glitch (like a network share becoming unreachable for a few seconds due to a VMware snapshot) and there seems to be no documented way to recover from such an interruption - it just stops logging until the application is restarted. Version: v2.0.8

App.config section:

<log4net>
    <appender name="RollingFile" type="log4net.Appender.RollingFileAppender" >
      <file type="log4net.Util.PatternString" value="K:\SomeApp-%property{log4net:HostName}-log.txt" />
      <appendToFile value="true" />
      <rollingStyle value="Size" />
      <maxSizeRollBackups value="40" />
      <maximumFileSize value="10MB" />
      <staticLogFileName value="true" />
      <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
      <errorHandler type="Acme.BusinessLayer.Log4NetErrorHandler" />
      <layout type="log4net.Layout.PatternLayout">
        <header value="[START] " />
        <footer value="[END] " />
        <conversionPattern value="%date %-5level %logger - %message%newline" />
      </layout>
    </appender>
    <root>
      <level value="DEBUG" />
      <appender-ref ref="RollingFileAppender" />
    </root>
</log4net>

Note: I am using log4net.Core.IErrorHandler, so that I can dispatch an email about the issue.

How can I resurrect/restart the logging when the log file is again accessible (which is usually only a matter of seconds)?

来源:https://stackoverflow.com/questions/54526848/log4net-stops-logging-how-to-recover

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!