Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,728,429 Members 53,937 Now Online
XDA Developers Android and Mobile Development Forum

[GUIDE] How to Logcat

Tip us?
 
Falcon G
Old
(Last edited by Falcon G; 16th May 2014 at 08:40 AM.)
#1  
Falcon G's Avatar
Senior Member - OP
Thanks Meter 315
Posts: 227
Join Date: May 2014
Default [GUIDE] How to Logcat

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))


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!)

This is a share.original thread
The Following 2 Users Say Thank You to Falcon G For This Useful Post: [ Click to Expand ]
 
TheStrix
Old
#2  
TheStrix's Avatar
Senior Member
Thanks Meter 65
Posts: 256
Join Date: May 2014
Location: Mumbai

 
DONATE TO ME
Hmmm.. I think all can see original guide in Android section...
There's no need of posting it again..
Anyway.. Thanks..
Press THANKS if I deserve it!!
 
Falcon G
Old
#3  
Falcon G's Avatar
Senior Member - OP
Thanks Meter 315
Posts: 227
Join Date: May 2014
Quote:
Originally Posted by TheStrix View Post
Hmmm.. I think all can see original guide in Android section...
There's no need of posting it again..
Anyway.. Thanks..
I think that it is good for moto E users, most of them are newbies, so they won't have to search a lot
The Following User Says Thank You to Falcon G For This Useful Post: [ Click to Expand ]
 
jaspreet997
Old
#4  
jaspreet997's Avatar
Senior Member
Thanks Meter 106
Posts: 479
Join Date: Jul 2013
What's the difference BTW logcat and androids inbuilt Bug report functionClick image for larger version

Name:	uploadfromtaptalk1400465767702.jpg
Views:	30
Size:	73.7 KB
ID:	2751421

Sent from my XT1033 using Tapatalk
 
Falcon G
Old
#5  
Falcon G's Avatar
Senior Member - OP
Thanks Meter 315
Posts: 227
Join Date: May 2014
Quote:
Originally Posted by jaspreet997 View Post
What's the difference BTW logcat and androids inbuilt Bug report functionAttachment 2751421

Sent from my XT1033 using Tapatalk
Logcat gives you the messages of the system logs and you can submit them to a developer manually. Bug report is kinda an automatic thing that keeps track of your errors
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes