I am trying to create my own website. To implement error handling, I would like to write to the event log. For this, I am trying to use the following code:
protected void btnExceptionTester_Click(object sender, EventArgs e)
{
try
{
throw new Exception("this is a test");
}
catch (Exception ex)
{
SPSecurity.RunWithElevatedPrivileges(delegate()
{
EventLog.WriteEntry("TestWebpart", ex.ToString(), EventLogEntryType.Error);
});
}
}
When I try to execute this code, I get a sharepoint error page (unhandled exception). When I look in the event log, I see the following message; "Requested registry access is not allowed."
I run (for testing only) under a full level of trust. Can someone tell me what privileges I need to write in the event log? Or is there a different approach?
Help to tell a lot!
source
share