问题描述
人们似乎对log4net的是否是线程安全的一些讨论,一致认为该框架是线程安全的,但附加目的地不是,需要正确的使用来实现线程安全。有人可以发光一些轻就这个问题和可能给予的例子可以说RollingFileAppender进行使用一个线程安全的方式?它需要推入背景?不知何故被锁定,还是什么?
There seems to be some discussion on whether log4net is thread-safe, the consensus is that the framework is thread-safe, but appenders are not and need to be used correctly to achieve thread-safety. can someone shine some light on this and possibly give example of lets say RollingFileAppender used in a thread-safe way? does it need to be pushed into context? somehow locked, or what?
推荐答案
根据这个link, RollingFileAppender进行是线程安全的(就记录而言)。这是从log4net的的开发者之一到来。他特别指出,锁定像这样不需要在code:
According to this link, RollingFileAppender is thread safe (as far as logging is concerned). This is coming from one of the developers of log4net. He specifically says that locking like this is not required in your code:
lock(logger)
{
logger.Info("Hello!");
}
这篇关于log4net的的线程安全的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!