Registration of the TraceProvider

Sep 10, 2009 at 12:41 PM

I think that the re-registration of the trace provider on every WriteTrace call is not a good thing. There is a lot of overhead and it will lead to missed events in the log. I'm not exactly sure of the absolute correct way to do this but am researching it, so that's why I reviewed you package.


Sep 10, 2009 at 5:39 PM

It shouldn't register the provider on every write.  There is a check in the writetrace method that checks to see if it has already been registered and only makes the call to registertraceprovider if it has not already been registered.

If you're using this class from within SP, then this registration should occurr the first time you call writetrace or ULS.Log() after the app pool has been reset.

I do remember working on a utility ( that runs outside SharePoint, but I wanted to log into the ULS logs using this library.  I think I had problems with multiple registrations there and the fix was to explicitly call the registration method in advance.

The trace provider class, by the way, is from the SharePoint SDK.  I don't remember if I made any changes to it at all, but if I did, they are minimal.