问题
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