This project is read-only.

Registering and Unregistering

Sep 10, 2009 at 3:49 PM

I'm not too sure this is such a great idea.. -- Examination of the 12/logs indicates that it is normally done at a much higher level -- process or service. Certainly not each time a message is written to log...

Sep 10, 2009 at 4:22 PM

I had a flash when I was looking at the code you provided for testing Sharepoint.Diagnostics --

If the Win32 API is closely examined, there are some features are silimar between ULS Logging and Windows Event Logging. Why would it not be possible to create a traceprovider as a feature and register and unregister it with the featurehandler. This would allow a persistent logger that responds to the controller and would have the ability to presist long enough so that it could appear in the diagnostic logging page of Central Admin. 

Minor mods to you exising code would allow this.. I'm going to give it a shot.


Sep 10, 2009 at 4:26 PM

Thats actually a very good point.

I will add this is as an issue, and fix it for next release. I'm thinking that the fix is a static variable in the Logging method that checks whether the TraceProvider is registered or not. If it is registered the message is logged. If not the TraceProvider is registered and then the message is logged.

The only question left is when to Unregister the TraceProvider.
I'm thinking that a solution could be to modify the Trace class so it isn't static any longer. But requires an instance. When this instance is disposed the TraceProvider could be unregistered. However I would prefer that code refering the codebase isn't broken. So I would like to keep the static classes and methods.

If you have any goods ideas on solving this, let me know.

Sep 10, 2009 at 4:34 PM

Good idea. 

I will implement your suggestion by
1) Adding a Farm scoped feature to the package. The farm scoped feature will in its Activate Event Register the TraceProvider, and in its DeActivate event UnRegister the TraceProvider.
2) Remove the calls to the Register and Unregister methods in the LogMessage Method.

Sep 10, 2009 at 4:35 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.