Writing to the Eventlog

M

mcw.willart

Hi,

I want to write events to the Apllication log and I'm trying to create
a custom source. When I run the app I get "The source was not found,
but some or all event logs could not be searched. Inaccessible logs:
Security.",
which is pretty normal, as users don't have rights to read/write the
Security log. But all I want to do is be able to create custom sources
an write them to the Application log.

Any ideas?

Greetings,

Mario
The Netherlands
 
A

Alberto Poblacion

I want to write events to the Apllication log and I'm trying to create
a custom source. When I run the app I get "The source was not found,
but some or all event logs could not be searched. Inaccessible logs:
Security.",
which is pretty normal, as users don't have rights to read/write the
Security log. But all I want to do is be able to create custom sources
an write them to the Application log.

You create the event source with "CreateEventSource":

if(!EventLog.SourceExists("MySource")){
EventLog.CreateEventSource("MySource", "MyLog");
}

But notice that the code needs to be running whith administrative rights to
create the eventsource. Once it is created, ordinary users can write events
using this source.

See also http://support.microsoft.com/kb/842795
 
P

Peter Bradley

I'm not sure if this is the same or a different problem, but we get
something similar when we try to write to a non-existent log from, say, a
Web service. The problem is that the Web service default user does not have
permission to create logs. It does, however, have permission to write to
pre-existing application logs, so our workaround is to create the custom log
by hand (we've written a little application to do it). The application then
writes to it with no problem.

HTH


Peter
 
R

Rad [Visual C# MVP]

Hi,

I want to write events to the Apllication log and I'm trying to create
a custom source. When I run the app I get "The source was not found,
but some or all event logs could not be searched. Inaccessible logs:
Security.",
which is pretty normal, as users don't have rights to read/write the
Security log. But all I want to do is be able to create custom sources
an write them to the Application log.

Any ideas?

Greetings,

Mario
The Netherlands
If you have an installer, you could add some code to create the custom
source during installation, since you generally need admin rights to
install software. That way the user will not have the security issue
when trying to create the source
 
M

mcw.willart

I'm not sure if this is the same or a different problem, but we get
something similar when we try to write to a non-existent log from, say, a
Web service. The problem is that the Web service default user does not have
permission to create logs. It does, however, have permission to write to
pre-existing application logs, so our workaround is to create the custom log
by hand (we've written a little application to do it). The application then
writes to it with no problem.

HTH

Peter








- Show quoted text -

Ok,

what I think the problem is, is when you check if a source exists,
e.g. if(!EventLog.SourceExists("MySource")), the security log is also
being searched, and a regular user does not have the rights to browse
through the security log. What I did is the same as Peter did, just
create the custom source by hand and then the app can write to this
source with no problem.

Greetings,

Mario
 

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

Top