Jump to content

Logcat: A guide


Recommended Posts

Posted (edited)

Logcat is the command to view the internal log of the Android system. Viewing logcat is often the best way - and sometimes the only way - to diagnose a problem.

Logcat is disabled on the phone by official ROMs by default. This needs to be enabled first which will then stay enabled unless you use an official update again.

Enabling Logcat

As logcat is disabled by default it'll need enabling from the terminal or using ADBl.

Through the terminal app:

su
echo 1 > /sys/kernel/logger/log_main/enable
echo 2 > /sys/kernel/logger/log_main/priority[/code] Through ADB:
[code]adb shell echo 1 > /sys/kernel/logger/log_main/enable
adb shell echo 2 > /sys/kernel/logger/log_main/priority
ADB Logcat The best way to get logs is with the Android Debug Bridge (ADB). This way you can view the log when the phone is otherwise unusable (e.g. booting or stuck in a loop). With ADB setup, run the following from the command line:
adb logcat
Note: Google have a sense of humor, and
adb lolcat
works identically. Press ctrl+c once you are done collecting information. To save a log to a file,
adb logcat > logcat.txt
ctrl+c[/code] [b]From the phone[/b] There are several ways to pull logs directly from the phone: [b]Terminal emulator[/b] You can also run logcat from the command line on the phone (terminal emulator, connectbot local, etc.):
[code]logcat
Obviously the screen is tiny and copying from the terminal is annoying, so, similar to adb logcat:
logcat > /sdcard/logfile.txt

and then press the trackball (for ctrl) and c to end the output.

aLogcat

Available on the Android Market, aLogcat will allow you to obtain and send a logcat with Google Mail or by other means. Usually it's best to mail the log to yourself, then copy the important bits into pastebin with a link to this in the relevant forum thread to have someone else diagnose the problem. Bug reports related to the Froyo test rom should be made on github.

Edited by flibblesan
Posted

hmm tried logcat command in terminal - nothing? so installed logcat app from market and get blank? do i need to wait for some time for logs to be read and outputted?

Posted
hmm tried logcat command in terminal - nothing? so installed logcat app from market and get blank? do i need to wait for some time for logs to be read and outputted?

Ah good spot. I'll need to add the information on how to enable logs.

Posted
how can we tell what the "important bits" are in the logcat?

With difficulty which is why you should just send the entire file when making a bug report.

Posted
Flibblesan should be a mod over the Modaco Pulse-forum.

I don't have enough time to do that.

Posted (edited)

On the few occasions I've had cause to look at logcat, I find that it's really confusing as there is tons of output, and finding what you are looking for is a bit like finding a needle in a haystack. :lol:

However I found this: Coloured Logcat Python Script

colorcat.png

./adb logcat | python /home/chris/android-sdk-linux_86/tools/coloredlogcat.py

Works for me! Much easier to track!!

A similar Windows app is available here Windows Coloured Logcat although I've not personally used this.

- Chris

Edited by chall32
  • 3 weeks later...
Guest Stevos
Posted
A similar Windows app is available here Windows Coloured Logcat although I've not personally used this.

Also, just to add - The ADT plugin for eclipse provides filter options to display only certain logcat levels and other features. Unlikely that people will want to install it unless they are doing development, but it's the best filtering system I've seen.

http://developer.android.com/sdk/eclipse-adt.html

(only use with eclipse-gallileo currently, NOT helios)

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.