4010 An unhandled security exception has occurred. IIS 8.5
 

I had this issue today and it was due to my asp.net application wanting to write to the Windows Event Log. The Event Source didn't exist and my application didn't have the permissions to create it so it errored with this message:

Event code: 4010 Event message: An unhandled security exception has occurred.

The fix for me was to create the Event Source and my application started working. I followed the steps from the below answer to manually create the Event Source via the command line:

How to create Windows EventLog source from command line?