views:

122

answers:

1

Is the way to check in ServiceBase's void OnStart, void OnStop methods, who initialized action? I need username to write it into log.

+1  A: 

You could take the currently logged on user. (my.user.name)

Or for example use the Autolog property. This will automatically write an entry to the event log when a service is started/stopped.

Mybase.AutoLog = true

I hope this answers your question, otherwise please let me know.

Rhapsody
Setting AutoLog property causes event log entries.This is not what i really need, because I would like to use my custom logger like log4net.There is another problem: many users can be loggeg on my server machine. I need to determine who exactly stopped service.
Bartosz Pierzchlewicz