Debug/Trace output in MonoDevelop

六月ゝ 毕业季﹏ 提交于 2019-12-10 17:31:31

问题


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.



来源:https://stackoverflow.com/questions/5680998/debug-trace-output-in-monodevelop

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!