Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Logging Xamarin Android-在发布模式下打印到应用程序输出_Logging_Xamarin_Xamarin.android - Fatal编程技术网

Logging Xamarin Android-在发布模式下打印到应用程序输出

Logging Xamarin Android-在发布模式下打印到应用程序输出,logging,xamarin,xamarin.android,Logging,Xamarin,Xamarin.android,要在三星和wiko设备上进行修补,我必须以发布模式在设备上运行我的应用程序。但是我希望在应用程序输出中看到System.Diagnostics.Debug.WriteLine的输出 我启用了开发人员工具,并在选项中定义了调试常量;我可以设置断点,但WriteLine输出仍然没有显示在控制台中。 我该怎么做?对于Xamarin.Android使用Android的Log实用程序,并查看/过滤您的消息的logcat输出 例子: Logcat输出(通过命令行或Android设备监视器): 正如他所说

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

我启用了开发人员工具,并在选项中定义了调试常量;我可以设置断点,但WriteLine输出仍然没有显示在控制台中。


我该怎么做?

对于
Xamarin.Android
使用Android的
Log
实用程序,并查看/过滤您的消息的
logcat
输出

例子: Logcat输出(通过命令行或Android设备监视器):
正如他所说。使用依赖关系服务来使用本机API编写日志,不要为此使用
System.Diagnostics.Debug.WriteLine
。在依赖项服务中,您甚至可以检查
DEBUG
标志,仅当DEBUG标志处于启用状态时才记录,从而获得与
System.Diagnostics.DEBUG.WriteLine
相同的行为(当然,您可以在需要时修改该行为)。FWIW:“我已经启用了开发人员检测,并在选项中定义了调试常量”-如果您进行了这些更改,实际上您所拥有的不再是“释放”模式。时间不同,JIT被禁用(因为您已附加了调试器)。最好不要进行这些更改-您仍然可以使用答案中提到的Android日志输出到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");
>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