SecurityException when calling LogToOperations

May 19, 2010 at 8:17 AM

I always get the following Exception, when calling the LogToOperations method:

One or more error occurred while writing messages into the log.\r\nThe error while writing to the EventLog was:An exception has occurred.
    ExceptionType: 'SecurityException'
    ExceptionMessage: 'Zugriff verweigert.'
    StackTrace: '   at Microsoft.SharePoint.Administration.SPPersistedObject.BaseUpdate()
           at Microsoft.SharePoint.Administration.SPDiagnosticsServiceBase.Update()
           at Microsoft.SharePoint.Administration.SPDiagnosticsServiceBase.GetLocalToFarm[T](SPFarm farm)
           at Microsoft.SharePoint.Administration.SPDiagnosticsServiceBase.GetLocal[T]()
           at Microsoft.Practices.SharePoint.Common.Logging.DiagnosticsService.get_Local()
           at Microsoft.Practices.SharePoint.Common.Logging.EventLogLogger.Log(String message, Int32 eventId, String category)
           at Microsoft.Practices.SharePoint.Common.Logging.SharePointLogger.WriteToOperationsLog(String message, Int32 eventId, String category)'
    Source: 'Microsoft.SharePoint'
    TargetSite: 'Void BaseUpdate()'

I'm using SPS2010 RTM and the drop 10 of the guidance package. The Application Pool is running under the Network Service account.

Did I miss something?


May 19, 2010 at 7:06 PM

Hi Markus,

This is a regression with RTM that we just discovered yesterday.  The issue is that the registration of the logger requires a higher permission level than is available in a content web.  As a result, the logger will need to be registered explicitly in your feature receiver, where you should have adequate permissions.  In your feature receiver FeatureInstalled or FeatureActivated event, add the following:


This will no longer be marked obsolete next drop, and we will update our documentation to indicate that the logger must be registered in an event receiver or in a admin script.