要在三星和wiko设备上修补some crash,我必须在发布模式下在设备上运行我的应用程序。但是我想在应用程序输出中看到System.Diagnostics.Debug.WriteLine的输出。

我启用了开发人员工具,并在选项中定义了DEBUG常量;我可以设置断点,但控制台中仍未显示WriteLine输出。
logging - Xamarin Android-在 Release模式下打印到应用程序输出-LMLPHP

logging - Xamarin Android-在 Release模式下打印到应用程序输出-LMLPHP

我能怎么做 ?

最佳答案

对于Xamarin.Android,请使用Android的Log实用程序,并监视/过滤消息的logcat输出。

例:

string TAG = "StackOverflow";
Log.Info(TAG,  $"This is a Info message: {DateTime.Now}");
Log.Debug(TAG, $"This is a debug message");
Log.Warn(TAG,  $"Warning! Warning! Will Robinson Warning! Warning!");
Log.Error(TAG, $"Error, contact support with error code 99 for assistance");


Logcat输出(通过cmd-line或Android设备监视器):

>adb logcat |grep StackOverflow

08-03 11:58:46.282  2338  2338 I StackOverflow: This is a Info message: 8/3/2016 11:58:46 AM
08-03 11:58:46.282  2338  2338 D StackOverflow: This is a debug message
08-03 11:58:46.282  2338  2338 W StackOverflow: Warning! Warning! Will Robinson Warning! Warning!
08-03 11:58:46.282  2338  2338 E StackOverflow: Error, contact support with error code 99 for assistance

10-01 02:38
查看更多