简体   繁体   English

记录实际上在Android设备上做了什么?

[英]What does logging actually do on an Android device?

I see code like this in Android samples all the time? 我一直在Android样本中看到这样的代码吗?

try { ... }
catch (Exception e) {
    Log.e("Error", e.getMessage());
}

What does Log.e actually do on a physical device? Log.e在物理设备上实际做了什么?

It goes to the system log, which devs can access through the SDK tools, through adb logcat or which you can access with apps like aLogcat. 它进入系统日志,开发人员可以通过SDK工具访问,通过adb logcat访问,也可以通过aLogcat等应用访问。 Debug log statements are generally removed by Android's default app release build process. 调试日志语句通常由Android的默认应用程序发布版本过程删除。

Log prints the line out to the system's console log which you can dump in real time using the adb tool. Log将该行输出到系统的控制台日志,您可以使用adb工具实时转储该日志。 Eg: adb logcat . 例如: adb logcat Or you can view it using the Eclipse-based debug tools. 或者您可以使用基于Eclipse的调试工具查看它。

My favorite log flavor is Log.wtf() . 我最喜欢的日志风格是Log.wtf()

The device keeps a rolling log called the logcat. 该设备保留一个名为logcat的滚动日志。 This can be read across ADB by several IDE or stand alone tools in the android SDK. 这可以通过Android SDK中的几个IDE或独立工具在ADB上读取。 Used this way it is a good debugging tool. 使用这种方式它是一个很好的调试工具。

On a device the logcat can be sent for remote debugging. 在设备上可以发送logcat以进行远程调试。

Log.e specifically is used to log errors but Log in general is used for all kinds of logging (errors, warnings, debug, verbose, etc). Log.e专门用于记录错误,但Log in general用于所有类型的日志记录(错误,警告,调试,详细等)。 These are very helpful for debugging an application. 这些对于调试应用程序非常有用。 Here, is a very good tutorial explaining this - Application Logging 这是一个非常好的教程解释这个 - 应用程序日志

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM