Changing the EventLog Source on the fly

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Changing the EventLog Source on the fly

GregT
Hi,

I have a custom event log called "MyApplication" and depending on where the error in my application originates from I want to indicate that as the source in the event log.

I.e., Database, Service, Client, etc.

I'm guessing that when I instantiate the logger I need to reset the source at that time?  Is this the best way to do this?

                        EventLogTarget target = LogManager.Configuration.FindTargetByName("eventlog") as EventLogTarget;
                        target.Source = "Database";

Has anyone tried to do this?

Thank you - Greg.