Logcat not displaying my log calls
Asked Answered
G

31

117

I'm a total noob at Android programming, and wanted to learn how to debug my apps. I can't seem to have my Log.i|d|v calls displayed in the LogCat.

Here's the code that I'm using. As you can see I have defined a LOG_TAG constant, but can't seem to find it in the LogCat. I have also imported android.util.Log AND I have made sure that in my AndroidManifest I have "debuggable" set to TRUE.

I have also checked http://developer.android.com/reference/android/util/Log.html w/o any luck resolving this issue.

What am I doing wrong? Am I even looking in the right place? I've tried using the DDMS and Debug perspective as well w/o any luck. Any help to this noob would be greatly appreciated. Thanks.

My environment: Windows XP IDE = Eclipse Version: 3.6.1, Build id: M20100909-0800 Emulator = having it point to android sdk 2.1 api 7

//very basic HELLO World code with a couple of Log.i calls

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;

public class debugger extends Activity {
    private static final String LOG_TAG = "debugger";

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        Log.i(LOG_TAG, "line 13");
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        Log.i(LOG_TAG, "CREATING NOW");
    }
}
Godoy answered 19/11, 2010 at 19:28 Comment(5)
It doesn't look like you are doing anything wrong, are you sure that your Activity is being started? Do you have any filters set in the logcat view? Did you try command line version of logcat? (adb logcat)Armyworm
Yes, tried the command line and outputted to a txt file and still couldn't find it. I know the Activity started because I see the "Hello World" message in the emulator. I tried viewing the logcat with and without filters and still no luck.Godoy
Try the command line adb logcat and don't filter anything first. I am pretty sure your code is working and printing to the log.Potence
Does LogCat work at all? E.g. do you see log entries from another apps (system apps, for instance)?Walkon
It could be device specific. we sometime need to enable logs from phone hidden menu https://mcmap.net/q/120760/-huawei-logcat-not-showing-the-log-for-my-appSurpassing
M
144

When using Eclipse, in the DDMS perspective, make sure the correct device (propably emulator-xxxx) is selected and highlighted. Only then will you get the logcat output in the logcat view.

Also, the Android plugin is a bit quircky, and sometimes only shows the last line in the logcat view. If this happens, try to clear the log. After that, you should get all the log entries again (works for me anyway).

Monte answered 19/11, 2010 at 19:51 Comment(6)
Yes, all issues I've had as well. If you scroll within the Logcat view it won't scroll with future updates automatically until you scroll back to the bottom.Wellknown
Ha! I was fighting this for a while. Opened DDMS and I had an old emulator selected. Why it doesn't default to the currently running emulator is odd.Teodorateodorico
ddewaele's answer solved my problem, you just need to let LogCat where its focus should be. As a side note you do not have to change perspective to bring up the devices menu Just go Window>>Show View>> Other>> Android>> Devices to bring up the devices panelUltra
@yock I believe that's intentional as the assumption is you want to stop and read at the point you scrolled to.Soberminded
Hahaha I am so stupid I don't know what DDMS is and even where to find it.Longshoreman
This was the solution in Android Studio as well.Jugendstil
S
72

If all else fails:

I did all the above things and couldn't figure out what was wrong,

Test with:

adb logcat

to figure out that my entries were infact in logcat, but twas adt's quirks.

Fix:

Restart eclipse

This was the only thing that fixed it.

Spinoff answered 18/2, 2013 at 14:58 Comment(6)
This works, but I can't keep restarting Eclipse as this issue happens a lot for me. Does anyone have a better solution?Postilion
@KhaledAlanezi then should consider using logcat from command prompt or windows powershell (better).Spinoff
i just restart eclipse every time this happens and it always solves the issue. it usually happens once a day but i am already used to being disappointed from eclipse..Chimkent
@Chimkent be disappointed with eclipse no more, move to Android Studio, my friend :)Spinoff
For me using an emulator on a remote machine restarting eclipse does not work Logcat never shows anything but adb logcat is a good tip, it works so upvote.Carnay
@Carnay you should be using Android Studio if you're not yet using it, mate :-)Spinoff
D
12

I've had the same problem using Android Studio and managed to get around by selecting No Filters in the select box in the top right corner of LogCat. By doing this I started receiving everything Android logs in the background into LogCat including my missing Log calls.

enter image description here

Diu answered 11/11, 2014 at 16:14 Comment(0)
B
9

Restart Eclipse and check log cat will be displayed.

Brummell answered 9/1, 2014 at 10:45 Comment(0)
S
6

I figured out I was automatically importing com.sileria.Log (from some library project) instead of android.util.Log, where the latter was the correct one. Check your imports as well.

Si answered 25/8, 2013 at 9:14 Comment(0)
W
3

I've noticed that Eclipse will sometimes throw an exception upon starting an Android app, then LogCat stops updating. I've corrected that by simply restarting Eclipse. I'm not sure if you've tried that and I know it's far from an optimal solution, but I suspect that the Eclipse plugin still has a few bugs to iron out.

Wellknown answered 19/11, 2010 at 19:46 Comment(0)
J
3

I needed to restart the adb service with the command adb usb

Prior to this I was getting all logging and able to debug, but wasn't getting my own log lines (yes, I was getting system logging associated with my application).

Jennifferjennilee answered 9/8, 2011 at 1:44 Comment(1)
I also have this - not getting own log lines. But this didn't help :(Orchard
G
3

Easiest way:

Check in your logcat window - TOP RIGHT corner PAUSE button || (Pause receiving new logcat messages)

Few clicks + eventually restart eclipse (usually works in my case)

Gripper answered 22/3, 2012 at 16:27 Comment(0)
H
2

On Android Studio: Click on the green arrow pointing to the right to restart the logging; if it is not visible, click on the >> icons to locate it.

Harl answered 26/9, 2014 at 16:11 Comment(0)
G
2

There are a number of reasons why you might not see logs, most of which are listed below. Here are some steps to check most reasons:

  1. Make sure you don't have 'android:debuggable="false"' in your AndroidManifest.xml
  2. Make sure your logcat isn't paused and make sure you are scrolled to the bottom
  3. Your filters should either be 'no filters' or your current app
  4. You have the correct device selected in your logcat devices list
  5. If you're not getting any messages, try restarting adb. You can do that from Android Studio by clicking on the 'restart' icon, it's right after the print icon for logcat and it looks like a green curved arrow coming out of a box. If you don't see it, mouse over the '>>' that continues the icon menu when the logcat is too small.
Gilley answered 17/1, 2015 at 19:58 Comment(0)
E
2

QUICK FIX.

Just restart the eclipse

Works Perfect.

Erny answered 27/6, 2015 at 13:40 Comment(0)
K
1

I'm a newb as well to Android-Eclipse. Here's what it took for me to get LogCat messages to display in Eclipse: 1: add this to the class in which the logcat message is called: private static final String TAG = "MyActivity"; (per the documentation here)

2: add this Log.i(TAG, "inLayout - finished"); when you where you want to display a message

If the above doesn't work, then shutdonw Eclipse and restart it and rerun your project.

It should then work.

Kane answered 4/8, 2012 at 20:19 Comment(0)
S
1

There is one more thing to watch for:

On the top right side of the logcat there is a dropdown table for filtering messages by type. Make sure it's on the level you are looking for (if it will be on the assert level, it will likely leave your logcat empty).

Scutage answered 10/3, 2013 at 15:33 Comment(0)
C
1

Probably it's not be correct, and a little bit longer, but I solved this problem (Android Studio) by using this:

System.out.println("Some text here");

Like this:

try {
       ...code here...
} catch(Exception e) {
  System.out.println("Error desc: " + e.getMessage());
}
Chemist answered 21/12, 2014 at 21:3 Comment(0)
A
1

Please go to Task Manager and kill the adb.exe process. Restart your eclipse again.

or

try adb kill-server and then adb start-server command.

Anear answered 30/12, 2014 at 6:40 Comment(0)
E
1

I spent several hours on such case. I saw only touch keys logs. Nothing more. Problem was... smarthphone. After restarting was OK. Disconnecting cable caused problem returned. Had to restart it again. Looks like the Android USB communication is not well designed.

Electrocute answered 17/5, 2015 at 12:21 Comment(2)
Thank you! Actually, it was the USB setting on the phone's quick menu... with regard to USB debugging. I had gotten into the habit of changing from Charging Only, to Transfer Files. BUT, Charging Only is what made the logging work. I'm just getting back to Android programming after a few years away, and, this was really cramping my learning curve.Droll
Then, I was only getting some of the logging... everything recently added was ignored. Got that sorted with Clean and Rerun, in Android Studio.Droll
H
0

Using the SDK 4.0.3 you have to explicitly select it on debug configurations > project > target or else it will never show using Eclipse Indigo (3.7). Of course an eclipse restart ensues.

Halloran answered 19/4, 2012 at 17:24 Comment(0)
B
0

I had a problem seeing simple log output in logcat as well. My problem was solved when I installed the latest JDK. I just setup a new development machine and only had the JRE installed and instaling the JDK worked for me.

Batt answered 11/5, 2013 at 16:24 Comment(0)
P
0

None of the other answers worked for me, but this did:

I removed my project from my workspace, then deleted anything that started with a dot (.settings, .project, etc.) from the project folder. Then I re-imported the projected. I'm missing some settings and breakpoints but at least it works.

Pomposity answered 1/8, 2013 at 14:31 Comment(0)
A
0

I had been experiencing this problem and nothing seemed to work until I moved the log call into a handler. Now it works every time, no matter where you are at.

Accepted answered 20/11, 2013 at 19:22 Comment(0)
I
0

I made the mistake of typing in a search term in the logcat search box. I forgot to delete it and hence couldn't see the new logs. Since they didn't match my search term and weren't displayed.

Inhaul answered 9/1, 2014 at 9:46 Comment(0)
E
0

In my case, I had to remove this line:

    <application
         android:debuggable="false"  <!-- Remove this line -->
         ..../>

From Application tag in my Manifest file.

Emilyemina answered 25/10, 2014 at 9:8 Comment(0)
G
0

Best solution for me was restart adb server (while I have Enabled ADB integration in Android studio - Tools - Android - checked). To do this quickly I created adbr.bat file inside android-sdk\platform-tools directory (where is adb.exe located) with this inside:

adb kill-server
adb start-server

Because I have this folder in PATH system variable, always when I need restart adb from Android studio, I can write only into terminal adbr and it is done.

Another option to do this is through Android Device Monitor in Devices tab - Menu after click on small arrow right - Reset adb.

Glint answered 29/10, 2014 at 18:33 Comment(0)
W
0

For eclipse: 1) Go to ddms perspective. 2) Make sure that correct device is selected. 3) If already selected and not displaying logs, then restart ABD. * Hope this will solve.

Wert answered 29/5, 2015 at 9:28 Comment(0)
T
0

I restarted the ADB service as well with "adb usb" and fixes the problem for me. In fact, only one of my activities didn't log anymore. All the others did log stuff. After restart adb everything works like a charm again. For the other people who're searching for another solution: adb kill-server, adb start-server in CLI will often fix your problem aswell.

Telemark answered 3/7, 2015 at 10:26 Comment(0)
B
0

make your app force close once this will start LogCat again ...

use this for force close :D

setContentView(BIND_AUTO_CREATE);
Bondie answered 8/2, 2016 at 13:25 Comment(0)
A
0

some times the problem is not from pc on the other hand IDE,ADB etc, but it arises from your device that doesn't send logs to ADB so if you tried all the ways mentioned before and still your logcat is empty try to restart your device and try again.I tried all the ways mentioned above and neither of them worked but after a restart on my phone logcat worked like magic

Ambition answered 5/11, 2016 at 13:25 Comment(3)
How to check if the device is able to send logs to ADB?Rosalie
@JCarlos try restarting your device if none of the solutions above workedAmbition
The AndroidMonitor shows the messages when I use the Log and run the app from my smartphone, but it is not working from my smartwatch. I was looking the settings but all seems good.Rosalie
T
0

I have this problems and fixed, String TAG without space:

"my tag" // noting show
"my_tag" // is ok

Trotskyite answered 7/6, 2017 at 6:36 Comment(0)
W
0

In my case I just had to add a name to the String. In first instance I just had a space in between the brackets

private static final String TAG = " ";

but after adding a name it worked perfectly.

private static final String TAG = "oncreate";
Waterfall answered 4/5, 2018 at 15:4 Comment(0)
V
0

After upgrade to Android 3.6.1, I have experienced this issue multiple times. The only thing that works in my case is RESTARTING THE DEVICE.

Vascular answered 12/3, 2020 at 15:57 Comment(0)
S
-3

You're trying to put Running Code on Working space.. so try to put your code on running code..

Syllabogram answered 20/4, 2014 at 4:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.