Using the Microsoft.Diagnostics.Tracing EventSource library (not to be mistaken for the System.Diagnostics.Tracing), it is possible to log certain messages to the event viewer by adding an Attribute to the Event annotation called 'Channel'. However this dumps the output to the 'Windows Logs\Application' area. How can I get this to log to 'Applications and Service Logs\MyApp\MyFeature' ?
Example code:
[EventSource(Name = "MyDemoApp")]
public sealed class MyDemoEventSource : EventSource
{
private MyDemoEventSource () { }
...
public const EventTask MyDemoTask = (EventTask) 12345;
...
[Event(12345,
Message = "My Demo Error: {0}",
Level = EventLevel.Warning,
Channel = EventChannel.Admin,
Task = Tasks.MyDemoTask,
Keywords = Keywords.Rule,
Opcode = Opcodes.Fail)]
private void SomethingWentWrong(string ErrorMessage)
{
WriteEvent(12345, ErrorMessage);
}