tags:

views:

452

answers:

5

I have written:

.
.
.
//Log exception to the event log
if (!EventLog.SourceExists("PodaHIS")) {
    EventLog.CreateEventSource("PodaHIS", "Application");   
}

EventLog eventLog = new EventLog();
eventLog.Log = "Application";
eventLog.Source = "PodaHIS";
eventLog.WriteEntry(error.ToString(), EventLogEntryType.Error);

I have also enabled read permission to LOCALMACHINE\ASPNET.

And in return i get:

The source was not found, but some or all event logs could not be searched. Inaccesible logs: Security.

Does anyone know why this is happening?

A: 

I think that a higher level of access is required to create a source in the event log. It's possible that the reference to Security log is coincidental and it is just reporting that as a possible cause. If you go in as an administrator and create the PodaHIS source yourself, you might then find that it can write to it.

Rob Kent
The current user has administrative rights.
Colour Blend
A: 

The application you are trying to log with is running without permissions to write to the event log.

Oded
I know. I have enable permissions and it still says that.
Colour Blend
Admin isn't always the needed permission
Oded
A: 

this kb artical explains the steps required to give your asp process the correct security rights to write to the event log...

kb

runrunraygun
My problem had to do with the Security sub key and the restarting of IIS.
Colour Blend
+2  A: 

HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\EventLog

What is need to do was grant the "Security" sub key of the EventLog Key read permission. After that i restarted my IIS.

Colour Blend
A: 

What it your deployment environment? If it is Vista/Server 2008 then adding worker account into Administrators group won't work due to UAC.

This link explains the problem in details. But I would recommend try creating an event source manually so ASPNET won't need to create it...

Regent
I've found a solution if my answer below.
Colour Blend