如何打印字符串logcat的测试? [英] How to print a string to logcat for testing?

查看:231
本文介绍了如何打印字符串logcat的测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这个问题已经被问过,但我无法找到一个明确的答案。我是新来的Andr​​oid Studio和logcat的控制台混淆了我。我有一个字符串的日期和我想保持它的'轨道'的控制台,所以我知道什么样的价值它有。

我试着像 Log.i 的console.log ,但似乎他们不为工作命令我的。


  • 我应该在哪里写我的打印线code?

  • 我在哪里可以看到它时,它会打印?

  • 请我来运行整个应用程序(在模拟器或设备上),打印行到控制台?


解决方案

  

在哪里写我的打印线code?


这是由你。


  

我在哪里可以看到它时,它会打印?


在LogCat中:

您在Android视图(通常停靠在底部边缘左侧)得到这个。请注意,我有时遇到过你的应用程序自动施加滤波器(右边的下拉列表,上面的输出)似乎产生任何显示输出了一个错误。您可能需要根据日志级别去除过滤器,然后调整输出。

您还可以通过 亚行logcat 并在Android设备监视器(工具> Android的> Android设备监控从查看在命令行LogCat中在Android Studio主菜单)。


  

我必须运行应用程序孔(仿真器或通过设备)来打印线到控制台?


I know this question has been asked before, but I can't find a clear answer. I'm new to Android Studio and the logcat console confuses me. I have a string date and I want to keep 'track' of it in the console so I know what value it has.

I tried commands like Log.i and console.log, but they don't seem to work for me.

  • Where should I write my print line code?
  • Where can I see it when it gets printed?
  • Do I have to run the whole app (on the emulator, or on a device) to print the line to the console?

解决方案

Where do I write my print line code ?

That is up to you.

Where can I see it when it gets printed ?

In LogCat:

You will get this from the Android view (usually docked on the bottom edge on the left side). Note that I have sometimes encountered a bug where the automatically-applied filter for your app (right-hand drop-down list, above the output) seems to result in nothing showing up in the output. You may need to remove the filters, then adjust the output based on log level.

You can also view LogCat at the command line via adb logcat and in the Android Device Monitor (Tools > Android > Android Device Monitor from the Android Studio main menu).

Do I have to run the hole app (emulator or via a device) to print the line to the console?

Yes.

这篇关于如何打印字符串logcat的测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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