|
|
|
date: Mon, 25 Apr 2005 08:46:04 +0200,
group: microsoft.public.dotnet.myservices
back
Re: Service and EventLog
Hi Albert,
I've had similar problems when developing a service.
The way Event logging works, is that every event log has event sources.
These event sources can only log to the specific log you have assigned that
source to. Somewhere in your program, I'm sure you had code that created the
eventsource for a specific event log:
Something like:
if(!EventLog.SourceExists("MyLog", "MyService"))
{
EventLog.CreateEventSource("MyLog", "MyService",);
}
This was permanantly assigned now in the computers registery - The source
called "MyService" logs to the log "MyLog". You program cannot just go an
change that it wants to log to a different Log.
What you need to do is remove the EventLogSource from the MyLog Log.
You can do this in ASP.NET with the following code:
EventLog.DeleteEventSource("MyService");
And then use CreateEventSource again to assign the source to a different log
(AnotherLog).
You can also delete the eventsources from the registry.
These are located in HKLM\System\CurrentControlSet\Services\EventLog.
In this registry entry, you will see you event logs (Application, Security,
System, and probably MyLog), In each of these, will be entries for the
eventsources.
HTH
Steve
"Albert Krger" wrote in message
news:#OLlcIWSFHA.2932@TK2MSFTNGP09.phx.gbl...
> Hello,
>
> I have a problem at a service with the log property of an EventLog. For
some
> weeks I write a little service which works fine. This service write to his
> own event log entry. In the constructor of the service I have write
>
> MyEventLog.Source = "MyService"
> MyEventLog.Log = "MyLog"
>
> Now I want to change the log property:
>
> MyEventLog.Log = "AnotherLog"
>
> But if I do that the service don't start. I get the error message (I only
> translate the important part of the message from german to english):
>
> "... The Source "MyService" is not in protocoll "AnotherLog" registrated,
> but in protocoll "MyLog". The source and the log property must agree. You
> can set an empty string to Log..."
>
> When I set MyEventLog.Log to an empty string or to "MyLog" my service
works
> fine. But I can't change MyEventLog.Log to another string.
> Where is my mistake?
>
> Thanks
> Albert Krger
>
>
date: Sun, 1 May 2005 10:28:46 -0400
author: Steve Lutz
Re: Service and EventLog
Hello Steve,
thanks, that is the solution. I have found it by my self.
Albert
"Steve Lutz" schrieb im Newsbeitrag
news:OtEowrlTFHA.3156@TK2MSFTNGP10.phx.gbl...
> Hi Albert,
>
> I've had similar problems when developing a service.
>
> The way Event logging works, is that every event log has event sources.
> These event sources can only log to the specific log you have assigned
that
> source to. Somewhere in your program, I'm sure you had code that created
the
> eventsource for a specific event log:
>
> Something like:
> if(!EventLog.SourceExists("MyLog", "MyService"))
> {
> EventLog.CreateEventSource("MyLog", "MyService",);
> }
>
> This was permanantly assigned now in the computers registery - The source
> called "MyService" logs to the log "MyLog". You program cannot just go an
> change that it wants to log to a different Log.
>
> What you need to do is remove the EventLogSource from the MyLog Log.
>
> You can do this in ASP.NET with the following code:
> EventLog.DeleteEventSource("MyService");
>
> And then use CreateEventSource again to assign the source to a different
log
> (AnotherLog).
>
> You can also delete the eventsources from the registry.
> These are located in HKLM\System\CurrentControlSet\Services\EventLog.
> In this registry entry, you will see you event logs (Application,
Security,
> System, and probably MyLog), In each of these, will be entries for the
> eventsources.
>
> HTH
> Steve
>
>
>
>
>
>
>
> "Albert Krger" wrote in message
> news:#OLlcIWSFHA.2932@TK2MSFTNGP09.phx.gbl...
> > Hello,
> >
> > I have a problem at a service with the log property of an EventLog. For
> some
> > weeks I write a little service which works fine. This service write to
his
> > own event log entry. In the constructor of the service I have write
> >
> > MyEventLog.Source = "MyService"
> > MyEventLog.Log = "MyLog"
> >
> > Now I want to change the log property:
> >
> > MyEventLog.Log = "AnotherLog"
> >
> > But if I do that the service don't start. I get the error message (I
only
> > translate the important part of the message from german to english):
> >
> > "... The Source "MyService" is not in protocoll "AnotherLog"
registrated,
> > but in protocoll "MyLog". The source and the log property must agree.
You
> > can set an empty string to Log..."
> >
> > When I set MyEventLog.Log to an empty string or to "MyLog" my service
> works
> > fine. But I can't change MyEventLog.Log to another string.
> > Where is my mistake?
> >
> > Thanks
> > Albert Krger
> >
> >
>
>
date: Mon, 2 May 2005 08:45:07 +0200
author: Albert Krger
|
|