I’m using my own custom TextWriterTraceListener for adding timestamp to each logged line so that the output looks like this:
LoggingExperiments.exe Information: 0 : 13:11 Testing infos
LoggingExperiments.exe Error: 0 : 13:11 Testing errors
Here is the code:
class CustomTextWriterTraceListener : TextWriterTraceListener
{
public CustomTextWriterTraceListener(string file) : base(file)
{
}
public override void WriteLine(string message)
{
base.Write(DateTime.Now.ToShortTimeString());
base.Write("\t");
base.WriteLine(message); // #1
Writer.WriteLine(message); // #2
}
}
How to format the output so that it doesn’t have leading executable names on each line? Or to change the order of information logged?
Should I always call “Writer.WriteLine” and format it’s parameters (comment #2) or there is some other way to override this behavior and stay with calling base methods like in code marked as #1.
Can’t reproduce your behavior…
I’ve tried this code :
And Output is :
You can do in configuration file :
Take a look at traceOutputOptions
Here the MSDN reference