运行在单独的线程log4net的追加程序 [英] Running Log4Net appenders on separate thread

查看:178
本文介绍了运行在单独的线程log4net的追加程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我有我自己的记录系统,在该日志本质上是一个队列,用一个单独的线程监听到该队列,做所有的实际写入操作。该系统处理日志消息一吨,文件可以很容易超过10 MB的大小在几分钟内,这样做的实际记录的调用线程是不可行的。

Currently, I've got my own logging system, where the log is essentially a queue, with a separate thread listening to that queue and doing all of the actual write operations. The system processes a TON of log messages, files can easily exceed 10 MB sizes in minutes, so doing the actual logging in the calling thread is not feasible.

我可以'找不到资源网上,显示线程将如何在log4net的工作,如果log4net的支持这种消息传递架构已经,或其他类似的功能,在一个线程的环境中工作。是否有任何预先存在的功能,能帮我吗?

I can't find resources online that show how threading would work in log4net, if log4net supports this kind of message passing architecture already, or other similar features to work in a threaded environment. Are there any pre-existing features that would help me?

这是可能的,而无需创建一个log4net的包装?

Is this possible without creating a log4net wrapper?

推荐答案

您可能要重新考虑线程支持,如果你的日志数据依赖于特定的顺序是 - 线程可以与干扰,并最终发布日志条目乱序

You may want to rethink the threading approach if your log data depends on being in a specific order -- threading may interfere with that and end up posting log entries out of sequence.

您的可能的尝试使用MSMQ(或其他一些队列技术)来快速发布日志消息至其他进程,然后它会做的物理写入存储。这将保证消息出现在它们发送的顺序相同。

You could try using MSMQ (or some other queue technology) to quickly post the log messages off to some other process which will then do the physical writes to storage. This will guarantee that messages appear in the same order they were sent.

这篇关于运行在单独的线程log4net的追加程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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