EventLog que

My aplication has following lines of code

EventLog myLog = new EventLog("Debug Log");

myLog.Source="Trace Output";

EventLogTraceListener TraceListener = new EventLogTraceListener(myLog);

Debug.Listeners.Add(TraceListener);

Trace.Write("Successfully Excecuted Method..Trace");

Debug.Write("Successfully Excecuted Method..Debug");

Trace.AutoFlush=true;

If i add Trace.Listeners.Add(TraceListener);

why does it logs same log two times



Answer this question

EventLog que

  • Kuldeep R. Modi

    You're telling the framework to log debug messages (with Debug.Listeners.Add(TraceListener) and trace messages (with Trace.Listeners.Add(TraceListener);). So, if you have a call to Trace.Write and Debug.Write, you will have two event log messages.

  • EventLog que