Debug/Trace output in MonoDevelop
Where can I see System.Diagnostics.Debug and System.Diagnostics.Trace output in MonoDevelop? I would think it should appear in the ApplicationOutput window, but it's开发者_JS百科 nowhere to be found.
The Application Output window will show the results of Console.WriteLine.
If you want something that works with Visual Studio on Windows as well as on Mono, then add a static method like the following to your Program.cs file:
public static void WriteLine(String fmt, params Object[] args)
{
string op;
if (fmt == null)
op = String.Empty;
else if (args == null || args.Length == 0)
op = fmt;
else
op = String.Format(fmt, args);
Trace.WriteLine(op);
DateTime now = DateTime.Now;
string outString = String.Format("{0,4}-{1,2:0#}-{2,2:0#} {3,2:0#}:{4,2:0#}:{5,2:0#} : {6}",
now.Year, now.Month, now.Day,
now.Hour, now.Minute, now.Second,
op);
Console.WriteLine(outString);
}
The default trace listeners write to System.Diagnostics.Debugger.Log, which is only supported in Mono HEAD.
If you're like to see the output outside the debugger, or when using older versions of Mono, add a custom trace listener that writes to the console.
精彩评论