I am using the following code to log the exception, but it's not writing any logs into the file "mylistener.log". What am I missing here?
using System;
using System.Diagnostics;
namespace TraceSourceApp
{
class Program
{
private static TraceSource mySource = new TraceSource("TraceSourceApp");
static void Main(string[] args)
{
TextWriterTraceListener textListener =
new TextWriterTraceListener("myListener.log");
mySource.Listeners.Add(textListener);
int i = 10, j = 0, k;
try
{
k = i / j;
}
catch
{
mySource.TraceEvent(TraceEventType.Error, 12,
"Division by Zero");
}
mySource.Close();
}
}
}