Friday, June 24, 2005

How to fix problem with access to application log from ASP.NET

How to fix problem with access to application log from ASP.NET
If you get error:
"Requested registry access is not allowed"
during "EventLog.WriteEntry" operation, then do this:
1) Create win application which will create Event Source for application log:
EventLog.CreateEventSource
Example:
=====
private void TestForm_Load(object sender, System.EventArgs e)
{
System.Diagnostics.EventLog.CreateEventSource("LogName", "Application");
}
=====

2) You must have Administrator's privileges on the computer which will be used as Web Server (your ASP.NET code will log into Application log of this computer).
3) Execute "EventLog.CreateEventSource" piece of code.
4) Your Web-application must use only this "LogName" source in "EventLog.WriteEntry" method call.

No comments:

Followers

About Me

My photo
Email me: blog@postjobfree.com