I'm currently creating a Windows Service and just figured out (thanks to this answer) how to configure the service installer in order to create a custom event log source during installation. As I already figured out by myself, these custom event log sources require elevated privileges to be registered. And that's the reason why the registration happens during installation - because the service installation is always executed with elevated privileges. So far, so good.
However, I'm not 100% satisfied with that solution because, as it is stated in the documentation of ServiceInstaller:
The Log property for this source is set by the ServiceInstaller constructor to the computer's Application log.
And this is not what I want. I want the events to be registered in a custom log called "MyCustomLog". Moreover, I cannot just set my service's ServiceBase.EventLog.Log to "MyCustomLog". How can I individually set my service's EventLog.Log? And where do I have to do this?
As I didn't find an answer for my question yet, I thought of creating a custom view for my service events which should have then looked like below:
It does not replace a custom event log as the events are still registered to the Application log, but it enables me to have an overview of certain events that happened in my service, just like it would be in a custom event log. So, how do I programmatically create such custom views? Is that possible? And if so, where do I need to create them? Does the creation require elevated privileges, so it needs to be done inside the ServiceInstaller? Or could this easily be done inside my service's constructor?
I would appreciate answers concerning the feasibility of both of the approaches!