简体   繁体   中英

What does logging actually do on an Android device?

I see code like this in Android samples all the time?

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

What does Log.e actually do on a physical device?

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. Debug log statements are generally removed by Android's default app release build process.

Log prints the line out to the system's console log which you can dump in real time using the adb tool. Eg: adb logcat . Or you can view it using the Eclipse-based debug tools.

My favorite log flavor is Log.wtf() .

The device keeps a rolling log called the logcat. This can be read across ADB by several IDE or stand alone tools in the android SDK. Used this way it is a good debugging tool.

On a device the logcat can be sent for remote debugging.

Log.e specifically is used to log errors but Log in general is used for all kinds of logging (errors, warnings, debug, verbose, etc). These are very helpful for debugging an application. Here, is a very good tutorial explaining this - Application Logging

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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