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 nowhere to be found.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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);
}
回答2:
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.
标签:
monodevelop