Eventlog problems

  • Thread starter Richard Heesbeen
  • Start date
R

Richard Heesbeen

Hi All,

I'm writing an webservice and want to log errors etc. and thoughed the
Eventlog would be a nice place for it. The problem is that i can't seem to
write to my own log and source i'm getting ' Requested registry access is
not allowed ' i have set the asp.net account to have permission on the
registry entries but that doesn't help a bit. Writing to the Application log
with my own source works just fine. But i want my own log so not to flood
the Applications one!

what can i do about that? any suggestions?

Hopes someone can help me out,
Richard.
 
B

Brock Allen

When you try to write to an event log application that's not been registered,
the API tries to create the approproate registry entry. The ASP.NET worker
process identity doesn't have permissions to do that. You need to call EventLog.CreateEventSource
from an administrative account first.
 
S

Steve

Hi Richard,

Are you using System.Diagnostics? If not....

Try using the System.Diagnostics event log handlers to output to an Event
log. This should allow you to either specify an existing log to write to or
create a new one, and also will give you listeners etc. to manipulate output
tp the logs.

HTH,
Steve.
 
R

Richard Heesbeen

Hi Brock,

Thanks for your time,

I have created the entries in an installer class with CreateEventSource
like:

EventLog.CreateEventSource ( "MyLog", "MyLog" );

So the entries in the registry are there, but when i try to write to them in
the webservice with:

EventLog Log = new EventLog();
Log.Log = "MyLog";
Log.Source = "MyLog";
Log.WriteEntry ( ... );

Then i get the Exception, doing that in the installer works just fine, also
to my own source in the Application log works fine.

Any more suggestions?
Richard.
 
R

Richard Heesbeen

Hi Steve,

Thanks for your time,

I use the following code in the webservice:

using System.Diagnostics;

EventLog Log = new EventLog();
Log.Log = "MyLog";
Log.Source = "MyLog";
Log.WriteEntry ( ... );

Is this ok? Or i'm i doing something wrong here?

Richard.
 
R

Richard Heesbeen

I figured it out, a source name needs to be unique, may not exist in any
other log.

Thanks for your time,
Richard.
 

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,997
Messages
2,570,240
Members
46,830
Latest member
HeleneMull

Latest Threads

Top