None of the examples on TraceSource I found addresses multithreading. I create new instance of a class (SyncService) to serve a incoming request. When there is lots of activity there is multiple threads that need to use this TraceSource to log activities. How should I use this class for logging with performance and thread safety in mind? I have some opts in mind:
private static TraceSource _source; static SyncService() { _source = new TraceSource("mySrc"); }
in case above the thread safety is an issue. There is quite a lot logging so i don't want to make locks everywhere to guard access to TraceEvent-method. What about removing both static-keywords? Is there lots of overhead when all the requests do logging from their own TraceSource? Is there better solution than these 2? msdn states: "Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe." What should i thinks about that?