log4net的 - 如何知道当一个文件回滚?文件、log4net

由网友(晚风贩卖所)分享简介:我通过log4net的这改变每隔一小时创建日志文件。有没有办法知道什么时候该卷发生?就像在log4net的LIB来,我可以绑定,并执行操作的事件时,该事件被解雇?我不是在寻找code样,只知道如果此事件存在,在这种情况下他的名字。I have a log file created by log4net whic...

我通过log4net的这改变每隔一小时创建日志文件。 有没有办法知道什么时候该卷发生? 就像在log4net的LIB来,我可以绑定,并执行操作的事件时,该事件被解雇? 我不是在寻找code样,只知道如果此事件存在,在这种情况下他的名字。

I have a log file created by log4net which changes every hour. Is there a way to know when this roll occurs? Like an event in the log4net lib to which I could bind, and perform an action when this event is fired ? I'm not looking for code samples, just to know if this event exists, and in that case his name.

在此先感谢!

PS:当时是我的应用程序配置的,所以我不能简单地用一个定时器...

PS: the time is configurable in my app, so I can't simply use a timer...

推荐答案

我猜你正在使用RollingFileAppender进行。 在这种情况下,您需要使用您自己的appender从RollingFileAppender进行继承和覆盖RollOverRenameFiles做你的逻辑,加上原有的执行。 RollOverTime将是时间。由于这些被保护,需要使用继承来创建自己的实现。 请参阅 RollingFileAppender进行文档的详细信息。

I guess you are using RollingFileAppender. In this case you would need to use your own appender inheriting from RollingFileAppender and overwrite RollOverRenameFiles to do your logic plus the original implementation. RollOverTime would be the time. As these are protected, you need to create your own implementation using inheritance. See RollingFileAppender documentation for the details.

阅读全文

相关推荐

最新文章