Kashif Nizam Qureshi

Cannot open log for source . You may not have write access.

I had a code that writes to Event Viewer. When the non-system account runs the code, it was throwing this error.

Solution:

Just wrap up the code that writes to Event Viewer with RunWithElevatedPrivileges like the following.

Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(delegate()
{
EventLog.WriteEntry(“Inseyab”, errorText, EventLogEntryType.Error);
});

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s