Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is the Microsoft Enterprise Library 5.0 Logging Application Block thread safe?

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?

like image 533
John Mills Avatar asked May 28 '10 03:05

John Mills


1 Answers

Enterprise Library 5.0 logging is thread safe.

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.

like image 131
Randy supports Monica Avatar answered Oct 18 '22 02:10

Randy supports Monica