Custom Event Log Write Error

T

TJO

We are experiencing the following error when writing to a custom log file:
"Requested registry access is not allowed."

We have created the custom log file using the code below and then add full
permissions to the ASPNET account at the Registry Key
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog.

We do not experience the error when writing to the "Application" Event log
or if we run the code from a windows form application.

// Code Fails when writing to custom event log "SR_AppLog
EventLog appLog = new EventLog("SR_AppLog", ".");
appLog.Source = "SR_AppDev";
appLog.WriteEntry("foo bar: database error");
appLog.Dispose();


//Code executs when writing to "Application" event log
EventLog appLog = new EventLog("Application");
appLog.Source = "SR_AppSrc";
appLog.WriteEntry("foo bar: database error");
appLog.Dispose();

//Installer class to create the custom event log
namespace EventLogSourceInstaller

{

[RunInstaller(true)]

public class MyEventLogInstaller : Installer

{

private EventLogInstaller myEventLogInstaller;

public MyEventLogInstaller()

{

//Create Instance of EventLogInstaller

myEventLogInstaller = new EventLogInstaller();

// Set the Source of Event Log, to be created.

myEventLogInstaller.Source = "SR_AppDev";

// Set the Log that source is created in

myEventLogInstaller.Log = "SR_AppLog";


// Add myEventLogInstaller to the Installers Collection.

Installers.Add(myEventLogInstaller);

}

}

}
 
T

TJO

we have followed these instructions on your recommended article. The
problem with the article is that it explains how to set permission for the
"Application" event log. It then goes on to show how to create your own
Even Log using a custom installer class which is also what we have done.
Our problem is that we can write to the Application event log but not to the
custom event log. We only get the Acccess not allowed error when writing to
the custom event log. Writing to the Application event log is no problem.

Has anyone done this before? What sercurity setting should I look for ?



Stefano Pronti said:
Have a look at that:
329291 PRB: "Requested Registry Access Is Not Allowed" Error Message When
http://support.microsoft.com/?id=329291

Cheers,
Stefano Pronti

Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.


TJO said:
We are experiencing the following error when writing to a custom log file:
"Requested registry access is not allowed."

We have created the custom log file using the code below and then add full
permissions to the ASPNET account at the Registry Key
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog.

We do not experience the error when writing to the "Application" Event log
or if we run the code from a windows form application.

// Code Fails when writing to custom event log "SR_AppLog
EventLog appLog = new EventLog("SR_AppLog", ".");
appLog.Source = "SR_AppDev";
appLog.WriteEntry("foo bar: database error");
appLog.Dispose();


//Code executs when writing to "Application" event log
EventLog appLog = new EventLog("Application");
appLog.Source = "SR_AppSrc";
appLog.WriteEntry("foo bar: database error");
appLog.Dispose();

//Installer class to create the custom event log
namespace EventLogSourceInstaller

{

[RunInstaller(true)]

public class MyEventLogInstaller : Installer

{

private EventLogInstaller myEventLogInstaller;

public MyEventLogInstaller()

{

//Create Instance of EventLogInstaller

myEventLogInstaller = new EventLogInstaller();

// Set the Source of Event Log, to be created.

myEventLogInstaller.Source = "SR_AppDev";

// Set the Log that source is created in

myEventLogInstaller.Log = "SR_AppLog";


// Add myEventLogInstaller to the Installers Collection.

Installers.Add(myEventLogInstaller);

}

}

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,744
Latest member
CortneyMcK

Latest Threads

Top