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

If you get the error some thing like (while writing to the event log):

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

As quick solution is to increase or raise the user permissions temporarily to write the event log and then revert back the elevated permissions.

Below is the code:

System.Security.Principal.WindowsImpersonationContext wic = System.Security.Principal.WindowsIdentity.Impersonate(IntPtr.Zero);
--your Code to write to event log or any to do something which needs elevated permission--
wic.Undo();

Follow

Get every new post delivered to your Inbox.