RollingFileAppender,滚动后不再追加
我有一个滚动文件附加器,每天晚上它都会滚动文件。然而,当它滚动时,新文件只有一个日志条目。该文件似乎不再附加日志条目。如果我重新启动该服务,它会正确记录。
这是我的设置:
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="Log.txt"/>
<appendToFile value="true" />
<staticLogFileName value="true" />
<rollingStyle value="Date" />
<datePattern value=" yyyy-MM-dd" />
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<threshold value="DEBUG" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />
</layout>
</appender>
I have a rolling file appender and every night it rolls the file. However, when it rolls it, the new file only has one log entry. It seems that file is not appending log entries anymore. If I restart the service it logs correctly.
Here are my settings:
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="Log.txt"/>
<appendToFile value="true" />
<staticLogFileName value="true" />
<rollingStyle value="Date" />
<datePattern value=" yyyy-MM-dd" />
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<threshold value="DEBUG" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />
</layout>
</appender>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将 maxSizeRollBackups 设置为一个值(将 maxSizeRollBackups 设置为负 1 以允许无限数量的备份文件)
参考。
Set
maxSizeRollBackups
to a value perhaps (maxSizeRollBackups set to negative 1 to allow an infinite number of backup files)Ref.
我发现问题是什么了。我在配置中删除了这一行,并在滚动文件后开始正确附加:
I found what the issue was. I removed this line in the configuration and it started to append correctly after it rolled the file: