Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,770,879 Members 43,810 Now Online
XDA Developers Android and Mobile Development Forum

[Guide] How To Logcat

Tip us?
 
Khizar
Old
#1  
Account currently disabled - OP
Thanks Meter 7775
Posts: 6,890
Join Date: Feb 2012
Default [Guide] How To Logcat

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: [ Click to Expand ]
 
Pierre118
Old
#2  
Pierre118's Avatar
Senior Member
Thanks Meter 139
Posts: 452
Join Date: Apr 2011
Location: The Hague
Good work, Khizar. A very handy and usefull guide. Thanks.
Galaxy Note 3 N9005, @tkari4 XXUFNF4 MultiX v1.4, rooted, Knox 0x1
The Following User Says Thank You to Pierre118 For This Useful Post: [ Click to Expand ]
 
daxgirl
Old
#3  
daxgirl's Avatar
Senior Member
Thanks Meter 3005
Posts: 1,570
Join Date: Jun 2012
Location: Jerusalem
Perfect idea! Very good guide!!! As usual! Amazing job, my friend!

Sent from my SM-G900F using Tapatalk
Quote:
In real open source, you have the right to control your own destiny.

Linus Torvalds
The Following User Says Thank You to daxgirl For This Useful Post: [ Click to Expand ]
 
Khizar
Old
#4  
Account currently disabled - OP
Thanks Meter 7775
Posts: 6,890
Join Date: Feb 2012
Quote:
Originally Posted by Pierre118 View Post
Good work, Khizar. A very handy and usefull guide. Thanks.
Quote:
Originally Posted by daxgirl View Post
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: [ Click to Expand ]
 
antique_sonic
Old
#5  
antique_sonic's Avatar
Recognized Contributor
Thanks Meter 1094
Posts: 2,099
Join Date: Aug 2009
Location: Corner of the earth
Quote:
Originally Posted by daxgirl View Post
Perfect idea! Very good guide!!! As usual! Amazing job, my friend!

Sent from my SM-G900F using Tapatalk
agree !


Quote:
Originally Posted by Khizar View Post
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.
~WJ~
Learn.... Learn.... & Learn
Learn till you die, and you will die a happy man



Q & A for XNote Galaxy S5 (All Questions about X-Note Galaxy S5 PORT) :
[Q&A]X-Note G900F S5 PORT
The Following 2 Users Say Thank You to antique_sonic For This Useful Post: [ Click to Expand ]
 
Khizar
Old
#6  
Account currently disabled - OP
Thanks Meter 7775
Posts: 6,890
Join Date: Feb 2012
Quote:
Originally Posted by antique_sonic View Post
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: [ Click to Expand ]
 
antique_sonic
Old
#7  
antique_sonic's Avatar
Recognized Contributor
Thanks Meter 1094
Posts: 2,099
Join Date: Aug 2009
Location: Corner of the earth
Quote:
Originally Posted by Khizar View Post
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.
~WJ~
Learn.... Learn.... & Learn
Learn till you die, and you will die a happy man



Q & A for XNote Galaxy S5 (All Questions about X-Note Galaxy S5 PORT) :
[Q&A]X-Note G900F S5 PORT
The Following 2 Users Say Thank You to antique_sonic For This Useful Post: [ Click to Expand ]
 
fahadali2315
Old
#8  
fahadali2315's Avatar
Senior Member
Thanks Meter 5193
Posts: 2,697
Join Date: Sep 2013
Location: Nottingham

 
DONATE TO ME
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: [ Click to Expand ]
 
antique_sonic
Old
#9  
antique_sonic's Avatar
Recognized Contributor
Thanks Meter 1094
Posts: 2,099
Join Date: Aug 2009
Location: Corner of the earth
Quote:
Originally Posted by fahadali2315 View Post
Great idea bro. We finally have a proper logcat thread for our Note3. 👍

Sent from my SM-G900F using Tapatalk
~WJ~
Learn.... Learn.... & Learn
Learn till you die, and you will die a happy man



Q & A for XNote Galaxy S5 (All Questions about X-Note Galaxy S5 PORT) :
[Q&A]X-Note G900F S5 PORT

The Following 2 Users Say Thank You to antique_sonic For This Useful Post: [ Click to Expand ]
THREAD CLOSED
Subscribe
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes