log4net的 - 如何知道当一个文件回滚? [英] Log4net - How to know when a file is rolled?

查看:225
本文介绍了log4net的 - 如何知道当一个文件回滚?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过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将是时间。由于这些被保护,需要使用继承来创建自己的实现。
请参阅<一href="http://logging.apache.org/log4net/release/sdk/log4net.Appender.RollingFileAppenderMembers.html"相对=nofollow> 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.

这篇关于log4net的 - 如何知道当一个文件回滚?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆