FORUMS
Remove All Ads from XDA

[Guide]Howto LOGCAT

2,387 posts
Thanks Meter: 4,760
 
Post Reply Email Thread
I think this one is definitely needed for this forum. So posting this here.

Here's how to use logcat:
There are two main ways to do a logcat, within android, and through adb.
Logcat within android can be done one of two ways, through a Logcat app:
Here are two good examples are either: aLogcat or Catlog
I prefer catlog, because in my opinion it has a little bit nicer UI. Both of these programs can dump their logs to a txt file, which is very useful for debugging. Or, you can do it in terminal emulator (same rules as running through adb(see below))

From Moscow Desire:


On the other hand, using adb to run logcat, in my opinion is much more useful, because you can start using it when android boots (i.e. once the boot animation appears.)

The code for logcat to output to a file is
Code:
adb logcat > name of problem.txt
you can also do
Code:
adb logcat -f name of problem.txt
how I prefer to do it is this way:
Code:
adb logcat -v long > name of problem.txt
with the -v flag & the long argument, it changes output to long style, which means every line of logcat will be on its own line (makes it a little neater, imo)
Note: When outputting to a file, you will see a newline, but nothing printed, this is normal. To stop logcat from writting to a file, you need to press ctrl+c.

Here's where using logcat (via adb makes life really easy)
Lets say you find a problem you're having after looking at a logcat.

For example:
When I was trying to use a different ramdisk, wifi wouldn't work so I got a logcat that's almost 1300 lines long (a lot of stuff happens in the background)

So if you are searching for an error in the logcat file (it's always e/ for error, f/ for fatal. Those are the two main things that will break a system.)

Code:
D/dalvikvm(  871): GC_CONCURRENT freed 472K, 6% free 10224K/10823K, paused 1ms+6ms
V/AmazonAppstore.DiskInspectorServiceImpl(  871): Available blocks: 21981, Block size: 4096, Free: 90034176, Threshold: 5242880, withinThreshold? true
D/AmazonAppstore.UpdateService(  871): Received action: null from intent: Intent { cmp=com.amazon.venezia/com.amazon.mas.client.framework.UpdateService }
W/AmazonAppstore.UpdateService(  871): Confused about why I'm running with this intent action: null from intent: Intent { cmp=com.amazon.venezia/com.amazon.mas.client.framework.UpdateService }
D/dalvikvm(  890): GC_CONCURRENT freed 175K, 4% free 9375K/9671K, paused 2ms+3ms
V/AmazonAppstore.ReferenceCounter(  871): Reference (MASLoggerDB) count has gone to 0. Closing referenced object.
E/WifiStateMachine(  203): Failed to reload STA firmware java.lang.IllegalStateException: Error communicating to native daemon 
V/AmazonAppstore.UpdateService(  871): runUpdateCommand doInBackground started.
V/AmazonAppstore.UpdateService(  871): Running UpdateCommand: digitalLocker
V/AmazonAppstore.UpdateCommand(  871): Not updating key: digitalLocker from: 1334228488057
V/AmazonAppstore.UpdateService(  871): Finished UpdateCommand: digitalLocker
V/AmazonAppstore.UpdateService(  871): Running UpdateCommand: serviceConfig
V/AmazonAppstore.MASLoggerDB(  871): performLogMetric: Metric logged: ResponseTimeMetric [fullName=com.amazon.venezia.VeneziaApplication_onCreate, build=release-2.3, date=Wed Apr 11 13:10:55 CDT 2012, count=1, value=1601.0]
V/AmazonAppstore.MASLoggerDB(  871): onBackgroundTaskSucceeded: Metric logged: ResponseTimeMetric [fullName=com.amazon.venezia.VeneziaApplication_onCreate, build=release-2.3, date=Wed Apr 11 13:10:55 CDT 2012, count=1, value=1601.0]
W/CommandListener(  118): Failed to retrieve HW addr for eth0 (No such device)
D/CommandListener(  118): Setting iface cfg
D/NetworkManagementService(  203): rsp 
D/NetworkManagementService(  203): flags 
E/WifiStateMachine(  203): Unable to change interface settings: java.lang.IllegalStateException: Unable to communicate with native daemon to interface setcfg - com.android.server.NativeDaemonConnectorException: Cmd {interface setcfg eth0 0.0.0.0 0 [down]} failed with code 400 : {Failed to set address (No such device)}
W/PackageParser(  203): Unknown element under : supports-screen at /mnt/asec/com.android.aldiko-1/pkg.apk Binary XML file line #16
D/wpa_supplicant(  930): wpa_supplicant v0.8.x
D/wpa_supplicant(  930): random: Trying to read entropy from /dev/random
D/wpa_supplicant(  930): Initializing interface 'eth0' conf '/data/misc/wifi/wpa_supplicant.conf' driver 'wext' ctrl_interface 'N/A' bridge 'N/A'
D/wpa_supplicant(  930): Configuration file '/data/misc/wifi/wpa_supplicant.conf' -> '/data/misc/wifi/wpa_supplicant.conf'
D/wpa_supplicant(  930): Reading configuration file '/data/misc/wifi/wpa_supplicant.conf'
D/wpa_supplicant(  930): ctrl_interface='eth0'
D/wpa_supplicant(  930): update_config=1
D/wpa_supplicant(  930): Line: 4 - start of a new network block
D/wpa_supplicant(  930): key_mgmt: 0x4
(mind you, that's 29 lines out of 1300ish, just for example)

I then could do the following with logcat:
Code:
adb logcat WifiStateMachine:E *:S -v long > name of problem.txt
and this will only print out any errors associated with WifiStateMachine, and anything which is fatal, which makes it about a million times easier to figure out what's going on!

In WifiStateMachine:E, the :E = to look for Errors, the full list of options is as follows:
V — Verbose (lowest priority)
D — Debug
I — Info (default priority)
W — Warning
E — Error
F — Fatal
S — Silent (highest priority, on which nothing is ever printed)

You can replace the :E with any other letter from above to get more info.
In order to filter out anything other than what you are looking for (in this case, WifiStateMachine) you must put a *:S after your last command (i.e. WifiStateMachine:E ThemeChoose:V ... ... AndroidRuntime:E *:S)

Sources: http://developer.android.com/tools/help/logcat.html
http://developer.android.com/tools/help/adb.html

Update for windows users:
Thank go to FuzzyMeep Two, Here's what he's posted for windows


(If you used his tool, here's his post, thank him for his work!)

Note : I am just sharing. Original post here.

Don't be a noob. Be a newbie..!!
Details here.
The Following 49 Users Say Thank You to Shaaan For This Useful Post: [ View ] Gift Shaaan Ad-Free
 
 
9th July 2012, 05:04 PM |#2  
PulseDroid's Avatar
Senior Member
Thanks Meter: 2,439
 
More
Great Guide! Should become a sticky.
9th July 2012, 05:41 PM |#3  
Prawesome's Avatar
Senior Member
Flag Error 404- Not found
Thanks Meter: 1,737
 
More
You know,today morning you said you were not an expert with logcats.I see this thread and i am awestruck,but then i read the second last line :|
The Following 2 Users Say Thank You to Prawesome For This Useful Post: [ View ] Gift Prawesome Ad-Free
9th July 2012, 07:46 PM |#4  
Shaaan's Avatar
OP Inactive Recognized Developer
Flag Mumbai
Thanks Meter: 4,760
 
Donate to Me
More
Quote:
Originally Posted by Prawesome

You know,today morning you said you were not an expert with logcats.I see this thread and i am awestruck,but then i read the second last line :|

I said i am no expert. That doesn't mean i cannot take, read or understand logcat..!!

Don't be a noob. Be a newbie..!!
Details here.
The Following 5 Users Say Thank You to Shaaan For This Useful Post: [ View ] Gift Shaaan Ad-Free
1st August 2012, 09:02 PM |#5  
eagleeyetom's Avatar
Developer Committee Lead / XDA Portal Team / Senior Moderator
Flag Gdańsk
Thanks Meter: 15,013
 
Donate to Me
More
This thread is perfect to be a sticky in the Android Development Section.
Newcommers should know how to properly report bugs. I also leave a redirect in the Original Android Development.
The Following 4 Users Say Thank You to eagleeyetom For This Useful Post: [ View ] Gift eagleeyetom Ad-Free
1st August 2012, 11:38 PM |#6  
Peteragent5's Avatar
Senior Member
Flag Richmond
Thanks Meter: 2,050
 
Donate to Me
More
I rather use ddms for all
17th September 2012, 02:22 PM |#7  
panpjp's Avatar
Senior Member
Flag Bangkok
Thanks Meter: 91
 
More
Command prompt is the most basic thing same old Windows

Sent from my GT-P7300 using xda app-developers app
4th October 2012, 12:24 PM |#8  
BlueSteelSS's Avatar
Member
Flag Singapore
Thanks Meter: 5
 
More
helped me out. Thanks
The Following User Says Thank You to BlueSteelSS For This Useful Post: [ View ] Gift BlueSteelSS Ad-Free
10th October 2012, 02:15 PM |#9  
dragonnn's Avatar
Senior Member
Thanks Meter: 872
 
More
Fro "noobs" it will be easier to use qtadb https://qtadb.wordpress.com/download/ , just download, install and run. Nice GUI for adb, contains access to logcat too.
The Following 2 Users Say Thank You to dragonnn For This Useful Post: [ View ] Gift dragonnn Ad-Free
22nd October 2012, 10:05 AM |#10  
Prawesome's Avatar
Senior Member
Flag Error 404- Not found
Thanks Meter: 1,737
 
More
Quote:

Fro "noobs" it will be easier to use qtadb https://qtadb.wordpress.com/download/ , just download, install and run. Nice GUI for adb, contains access to logcat too.

And it colours out errors according to their priority

I am a potato, problem?
The Following User Says Thank You to Prawesome For This Useful Post: [ View ] Gift Prawesome Ad-Free
24th November 2012, 09:38 AM |#11  
AnoopKumar's Avatar
Senior Member
Flag Kerala
Thanks Meter: 479
 
More
Thanks bro

Sent from my GT-S5830 using Tapatalk 2
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes