Welcome to XDA

Search to go directly to your device's forum

Register an account

Unlock full posting privileges

Ask a question

No registration required
Thread Closed

[Guide] How To Logcat

OP Khizar

29th May 2014, 10:41 AM   |  #1  
Khizar's Avatar
OP Senior Member
Thanks Meter: 8,238
 
7,110 posts
Join Date:Joined: Feb 2012
More
I think this one is definitely needed for this forum as i am seeing more and more users ask how to logcat. 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.
The Following 5 Users Say Thank You to Khizar For This Useful Post: [ View ]
29th May 2014, 12:11 PM   |  #2  
Pierre118's Avatar
Senior Member
Flag The Hague
Thanks Meter: 157
 
482 posts
Join Date:Joined: Apr 2011
More
Good work, Khizar. A very handy and usefull guide. Thanks.
The Following User Says Thank You to Pierre118 For This Useful Post: [ View ]
29th May 2014, 12:44 PM   |  #3  
daxgirl's Avatar
Senior Member
Flag Jerusalem
Thanks Meter: 3,924
 
1,986 posts
Join Date:Joined: Jun 2012
More
Perfect idea! Very good guide!!! As usual! Amazing job, my friend!

Sent from my SM-G900F using Tapatalk
The Following User Says Thank You to daxgirl For This Useful Post: [ View ]
29th May 2014, 03:16 PM   |  #4  
Khizar's Avatar
OP Senior Member
Thanks Meter: 8,238
 
7,110 posts
Join Date:Joined: Feb 2012
More
Quote:
Originally Posted by Pierre118

Good work, Khizar. A very handy and usefull guide. Thanks.

Quote:
Originally Posted by daxgirl

Perfect idea! Very good guide!!! As usual! Amazing job, my friend!

Sent from my SM-G900F using Tapatalk

Thank you both but JFYI this isn't my work. I shared this guide on my previous phone and since it's so good and there is ALOT of need I shared it here as well. I mentioned that in the OP.

Sent From My SM-N9005 To All You Wonder Nobodies!!
Quote:

Due to the lack of mods, trolls can ruin the XDA forum's. Don't feed them...Instead report them.

The Following 3 Users Say Thank You to Khizar For This Useful Post: [ View ]
30th May 2014, 07:53 AM   |  #5  
antique_sonic's Avatar
Recognized Contributor
Flag Corner of the earth
Thanks Meter: 1,096
 
2,100 posts
Join Date:Joined: Aug 2009
More
Quote:
Originally Posted by daxgirl

Perfect idea! Very good guide!!! As usual! Amazing job, my friend!

Sent from my SM-G900F using Tapatalk

agree !


Quote:
Originally Posted by Khizar

Thank you both but JFYI this isn't my work. I shared this guide on my previous phone and since it's so good and there is ALOT of need I shared it here as well. I mentioned that in the OP.

Sent From My SM-N9005 To All You Wonder Nobodies!!

Though not pure your own work, but noobies will need it, especially to send a log back to devs to know what is the problem.
And it's a good thing to share here.
The Following 2 Users Say Thank You to antique_sonic For This Useful Post: [ View ]
30th May 2014, 07:58 AM   |  #6  
Khizar's Avatar
OP Senior Member
Thanks Meter: 8,238
 
7,110 posts
Join Date:Joined: Feb 2012
More
Quote:
Originally Posted by antique_sonic

agree !




Though not pure your own work, but noobies will need it, especially to send a log back to devs to know what is the problem.
And it's a good thing to share here.

Appreciate the support brother...

Sent From My SM-G900F-Morphed SM-N9005 With XNote Goodness To All You Wonder Nobodies!!
Quote:

Due to the lack of mods, trolls can ruin the XDA forum's. Don't feed them...Instead report them.

The Following 2 Users Say Thank You to Khizar For This Useful Post: [ View ]
31st May 2014, 04:16 AM   |  #7  
antique_sonic's Avatar
Recognized Contributor
Flag Corner of the earth
Thanks Meter: 1,096
 
2,100 posts
Join Date:Joined: Aug 2009
More
Quote:
Originally Posted by Khizar

Appreciate the support brother...

Sent From My SM-G900F-Morphed SM-N9005 With XNote Goodness To All You Wonder Nobodies!!

No worries Bro.


Sent from somewhere under the sky, at the corner of this rounded earth.
The Following 2 Users Say Thank You to antique_sonic For This Useful Post: [ View ]
31st May 2014, 06:17 AM   |  #8  
fahadali2315's Avatar
Senior Member
Flag Nottingham
Thanks Meter: 5,747
 
2,881 posts
Join Date:Joined: Sep 2013
Donate to Me
More
Great idea bro. We finally have a proper logcat thread for our Note3. 👍

Sent from my SM-G900F using Tapatalk
The Following 2 Users Say Thank You to fahadali2315 For This Useful Post: [ View ]
1st June 2014, 03:12 PM   |  #9  
antique_sonic's Avatar
Recognized Contributor
Flag Corner of the earth
Thanks Meter: 1,096
 
2,100 posts
Join Date:Joined: Aug 2009
More
Quote:
Originally Posted by fahadali2315

Great idea bro. We finally have a proper logcat thread for our Note3. 👍

Sent from my SM-G900F using Tapatalk


The Following 2 Users Say Thank You to antique_sonic For This Useful Post: [ View ]
Thread Closed Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes