使用 log4cxx 作为输入计数器
我想添加一个计数器来记录每小时或每天输入的数据量。
由于我的代码中没有计时器,我希望可以处理每日日志轮换的 log4cxx 可以帮助我。就像,每个午夜,打印一个日志,显示昨天有多少数据进入。
有谁知道这个技巧或有任何参考吗?
谢谢。
I want to add a counter that record how many data input per hour or per day.
Since there is no timer in my code, I hope that log4cxx, which can handle daily log rotation, could help me. Like, every midnight, print a log showing how many data got in yesterday.
Do anyone know the trick or any reference?
THX.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个迟到的答案,但也许对其他人有用。
不,log4cxx 无法做到这一点——在给定时间自行打印日志。 Log4cxx 与计时器无关,滚动检测例程会通过库(更具体地说是附加程序)处理的每个日志语句进行检查。没有看门狗线程来触发任何行为。
This is a late answer, but maybe it's going to be useful to other people.
Nope, log4cxx cannot do it — print a log at a given time, out of itself. Log4cxx is not about timers, roll-over detection routine is checked with every log statement processed by the library, more specific, by the appender. There are no watchdog threads to trigger any behaviour.