如何为log4net创建异步包装? [英] How do I create an asynchronous wrapper for log4net?

查看:395
本文介绍了如何为log4net创建异步包装?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

默认情况下,log4net是一种同步日志记录机制,我想知道是否有一种方法可以使用log4net进行异步日志记录?

By default, log4net is a synchronous logging mechanism, and I was wondering if there was a way to have asynchronous logging with log4net?

推荐答案

如果您访问log4net网站,则可以找到一些示例,其中至少一个是异步Appender.

If you go to the log4net website, you can find some examples, at least one of which is an asynchronous Appender.

http://logging.apache.org/log4net/release/example- apps.html

请注意,我没有使用这些示例中的任何一个,因此我无法以任何一种方式为它们提供担保.

Note that I have not used any of these examples, so I cannot vouch for them one way or the other.

这是从代码存储区中的log4net示例区域到实际异步附加程序的链接:

Here is a link to the actual asynchronous appender from the log4net Examples area in their code repository:

http://svn.apache.org/viewvc/logging/log4net/trunk/examples/net/2.0/Appenders/SampleAppendersApp/cs/src/Appender/AsyncAppender.cs?view=markup

我简要地看了一下它,显然它充当了一个或多个传统" Appender的包装.在每个日志记录请求(包含一个或多个LoggingEvent对象)上,使用ThreadPool线程将LoggingEvents转发到已包装的Appender列表.

I looked at it briefly, and it apparently acts as a wrapper around one or more "conventional" Appenders. On each logging request (containing one or more LoggingEvent objects), a ThreadPool thread is used to forward the LoggingEvents to the list of wrapped Appenders.

这篇关于如何为log4net创建异步包装?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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