Xamarin Android-在发布模式下打印到应用程序输出 [英] Xamarin Android - Print to the application output in Release mode

查看:79
本文介绍了Xamarin Android-在发布模式下打印到应用程序输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要在三星和wiko设备上修补

我该怎么办?

解决方案

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

示例:

  string TAG ="StackOverflow";Log.Info(TAG,$这是一条信息消息:{DateTime.Now}"));Log.Debug(TAG,$这是一条调试消息");Log.Warn(TAG,$警告!警告!将鲁滨逊警告!警告!");Log.Error(TAG,$错误,请与错误代码99联系支持以获得帮助"); 

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

 > adb logcat | grep StackOverflow08-03 11:58:46.282 2338 2338 I StackOverflow:这是一条信息消息:2016/8/3 11:58:46 AM08-03 11:58:46.282 2338 2338 D StackOverflow:这是一条调试消息08-03 11:58:46.282 2338 2338 W StackOverflow:警告!警告!鲁滨逊会警告!警告!08-03 11:58:46.282 2338 2338 E StackOverflow:错误,请与错误代码99联系支持以获得帮助 

To patch some crash on samsung and wiko devices, I have to run my application on device in Release mode. But I would like to see the output of System.Diagnostics.Debug.WriteLine in the application output.

I've enabled developer instrumentation, as well as defined the DEBUG constant in the options ; I can set breakpoints, but the WriteLine outputs still aren't shown in the console.

How can I do ?

解决方案

For Xamarin.Android use Android's Log utility and watch/filter the logcat output for your messages.

Example:

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 Output (via cmd-line or Android Device Monitor):

>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

这篇关于Xamarin Android-在发布模式下打印到应用程序输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆