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
Post Reply

How to : Logcat for trouble shooting

OP Zirabius

24th October 2010, 08:40 PM   |  #1  
OP Member
Thanks Meter: 3
 
37 posts
Join Date:Joined: Oct 2010
Donate to Me
More
Hey guys,

So I was looking through XDA and did not find a good and informative article about how to do a Logcat.


What it is...


Logcat is like ECG (electrocardiogram) that is used to monitor your heart but its for your phone lol . It is command view that lets see the internal logs of your android system and shows you what apps are doing in the background.


What it do...

Logcat is not something that you would use every day but it is a great tool to trouble shoot your device using your computer. It will let you debug and you also you can find out whats killing your battery!



I know Its something pretty easy process for most of the people. but as a noob it was some thing that I spent couple of hours learning and I thought I should contribute in my own way.


here are the steps you need to follow!


1- Like always enable your Debugging. you can enable that by going to your Settings -> Application -> Development

2- Install the android SDK . you can download it
Android SDK

3- Extract the SDK to any folder, Example : C:\Android

4- Make sure you have the drivers installed- In that way your OS can talk to your phone!


now that everything is installed we can go ahead and perform a command :



1. Open the 'run' dialog by pressing the 'Windows' + 'r' buttons on your keyboard (minimize the browser & other non-windows programs)
2. cmd (this will open a DOS prompt)
3. cd c:\Android\tools (go to the directory where you extracted the SDK)
4. adb shell
5. Now you'll see just a '$'
6. logcat


You can now just press the power button on your phone to see what happens. It displays everything the device is doing.

So the thing is: leave your device connected for a while and see what is actually going on when you're not using it.


An Example

Twidroid auto refreshing my Tweets

HTML Code:
=> again nothing special  
D/dalvikvm(   75): GC freed 40165 objects / 1974768 bytes in 91ms 
D/dalvikvm( 1560): GC freed 25 objects / 1800 bytes in 53ms 
D/dalvikvm( 1687): GC freed 7551 objects / 330032 bytes in 102ms   

=> Twidroid doing it's thing  

I/ActivityManager(   75): Start proc com.twidroidpro:remote for service com.twidroid ...

   => back to freeing up the objects  

D/dalvikvm( 1287): GC freed 3 objects / 72 bytes in 95ms 
D/dalvikvm( 1253): GC freed 281 objects / 12688 bytes in 91ms

If you're seeing apps that are constantly busy when they shouldn't that means they're draining battery because of bugs in the app/ bad coding/ ...

Example of a buggy app:

HTML Code:
D/dalvikvm( 1287): GC freed 3 objects / 72 bytes in 92ms 
D/dalvikvm( 2216): GC freed 6646 objects / 313032 bytes in 104ms 
D/NetworkLocationProvider(   75): onCellLocationChanged [***] 
D/LocationManager( 2216): removeUpdates: listener = com.levelup.beautifulwidgets .UpdateWeather$2@447843d8 
D/dalvikvm( 1253): GC freed 281 objects / 12688 bytes in 93ms 
D/NetworkLocationProvider(   75): onCellLocationChanged [***] 
D/LocationManager( 2216): removeUpdates: listener = com.levelup.beautifulwidgets .UpdateWeather$2@447843d8 
D/dalvikvm(   75): GC freed 41839 objects / 1963448 bytes in 88ms
D/dalvikvm( 1287): GC freed 3 objects / 72 bytes in 94ms 
D/NetworkLocationProvider(   75): onCellLocationChanged [***] 
D/LocationManager( 2216): removeUpdates: listener = com.levelup.beautifulwidgets .UpdateWeather$2@447843d8
D/dalvikvm( 2216): GC freed 6657 objects / 314648 bytes in 35ms D/NetworkLocationProvider(   75): onCellLocationChanged [***] 
D/LocationManager( 2216): removeUpdates: listener = com.levelup.beautifulwidgets .UpdateWeather$2@447843d8 
D/dalvikvm( 1253): GC freed 279 objects / 12640 bytes in 94ms 
D/NetworkLocationProvider(   75): onCellLocationChanged [***] 
D/LocationManager( 2216): removeUpdates: listener = com.levelup.beautifulwidgets .UpdateWeather$2@447843d8 
D/dalvikvm( 1287): GC freed 3 objects / 72 bytes in 60ms 
D/dalvikvm( 2216): GC freed 6661 objects / 314192 bytes in 104ms 
D/NetworkLocationProvider(   75): onCellLocationChanged [***] 
D/LocationManager( 2216): removeUpdates: listener = com.levelup.beautifulwidgets .UpdateWeather$2@447843d8
As you can see the app (BeautifulWidgets) was constantly trying to remove the same updates and thus draining my battery for no reason. This was happening every 10seconds (!!).

Uninstalling those crappy apps should help your battery life (and hope a future update of that app fixes it)

The less you see in the logcat the better!

If you want to clear the log and only see what's happening on your phone from now on, go to adb shell (step 4) and then type logcat -c. This clears the log and then type logcat.



All the credit goes to FLT from android Forums

If there is anything wrong please do tell!
I hope this helps!
The Following 3 Users Say Thank You to Zirabius For This Useful Post: [ View ]
24th October 2010, 08:52 PM   |  #2  
Senior Member
Thanks Meter: 3
 
121 posts
Join Date:Joined: Mar 2010
Nicely done! Logcat is one of the most useful and least used tools out there, and this tutorial should go a long way toward changing that.
24th October 2010, 09:00 PM   |  #3  
Senior Member
Thanks Meter: 47
 
105 posts
Join Date:Joined: Sep 2010
Mmm, I used to use logcat as you described, but now I use an app called "aLogcat" found on the marketplace. Think it's the same thing, just an app you can run on your phone instead, so no need for a computer or adb shell to monitor what's going on.
Post Reply Subscribe to Thread

Tags
logcat
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes