Microsoft Enterprise Library 5.0日志记录应用程序块线程安全吗? [英] Is the Microsoft Enterprise Library 5.0 Logging Application Block thread safe?
问题描述
我有一些代码将从不同线程使用Enterprise Library 5.0中的Logging Application Block进行记录. LAB线程安全吗?我可以从不同的线程像正常日志一样记录日志,还是需要同步日志记录代码,以便一次只能在一个线程中使用?
I have some code that will be logging using the Logging Application Block in Enterprise Library 5.0 from different threads. Is the LAB thread safe? Can I log like normal from different threads or will I need to synchronize the logging code so that is only used from one thread at a time?
推荐答案
Enterprise Library 5.0日志记录是线程安全的.
Enterprise Library 5.0 logging is thread safe.
在记录之前,EL将检查TraceListener
的IsThreadSafe
属性.如果特定的TraceListener不是线程安全的,则它将在调用侦听器的TraceData
方法之前执行Monitor.Enter(listener);
.
Before logging, EL checks the IsThreadSafe
property of the TraceListener
. If the specific TraceListener is not thread safe then it will perform a Monitor.Enter(listener);
before calling the listener's TraceData
method.
这篇关于Microsoft Enterprise Library 5.0日志记录应用程序块线程安全吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!