在标题中,我试图通过以xamarin形式写入控制台来调试我的程序。我已经尝试了多步的System.Diagnostics.Debug.WriteLine和Console.WriteLine,并且它们都没有我在调试输出或设备日志中看到的任何输出。
编辑:
在Visual Studio Debug输出中看不到以下代码的输出。
using CustomRenderer;
using System;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace CarpApp
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class MainPage : ContentPage
{
private static ILogger logger = DependencyService.Get<ILogManager>().GetLog();
public MainPage()
{
InitializeComponent();
logger.Trace("Test1");
System.Diagnostics.Debug.WriteLine("Test2");
}
private void OnMessagesTapped(object sender, EventArgs args)
{
System.Diagnostics.Debug.WriteLine("Test3");
Console.WriteLine("Test4");
logger.Trace("Test5");
}
private void OnFindTapped(object sender, EventArgs args)
{
Navigation.PushAsync(new MapPage());
}
private void OnGetRidTapped(object sender, EventArgs args)
{
Navigation.PushAsync(new GetRidPage());
}
}
}
答案 0 :(得分:1)
作为一种解决方法,您可以将NLog日志记录添加到您的应用中(有关详细信息,请参阅This link)。 除FileTarget日志记录外,您还可以定义DebuggerTarget,它直接进入控制台。
答案 1 :(得分:0)
我终于解决了这个问题,问题是整个项目中都有很多搞砸的名字。