Friday, October 19, 2012

Microsoft SharePoint Patterns and Practices Logging Provider


Part of the patterns & practices SharePoint guidance published by Microsoft is a framework for doing logging (  The DLL provided (Microsoft.Practices.SharePoint.Common.dll) includes logger class that allows you to log messages easily to the ULS.  The one challenge is that it registers custom logging areas to accomplish this.  We were struggling to get one of these areas registered because the .NET feature trying to register the area did not have the proper privileges at runtime.  To avoid giving the feature the required farm wide permissions it needed, I instead opted to register the logging area via PowerShell.  Two PowerShell commands later, voil√†:

PS C:\> [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Practices.SharePoint.Common")

GAC Version Location
--- ------- --------
True v2.0.50727 C:\Windows\assembly\GAC_MSIL\Microsoft.Practices.SharePoint.Common\\Microsoft.Practices.SharePoint.Common.dll

PS C:\> [Microsoft.Practices.SharePoint.Common.Logging.DiagnosticsService]::Register()

No comments:

Post a Comment