9

Android studio does not show any Logs I wrote in my code. I have tried putting the log to verbose and debug. I am using 'No filters'. Why is 'Oncreatetestlog' not showing up in my logcat?

package com.example.keydown;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;

public class MainActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        if (savedInstanceState != null) {
            Log.d("Oncreatetestlog", "onCreate() Restoring previous state");
            /* restore state */
        } else {
            Log.d("Oncreatetestlog2", "onCreate() No saved state available");
            /* initialize app */
        }
    }
}
P.Yntema
  • 548
  • 2
  • 8
  • 28

5 Answers5

18

Go to File -> invalidate caches / Restart. And let Android Studio index your project again. It works for me.

Taras Mykhalchuk
  • 594
  • 7
  • 14
  • I tried, when I search the logcat for 'Oncreatetestlog' it doesn't show anything. Still not writing. – P.Yntema Oct 10 '16 at 15:40
  • This helped me when new logging was making no effect on Android Emulator.. – Štěpán Apr 01 '20 at 14:45
  • 1
    For anyone coming back to this: modify the filters. Mine was set to firebase for some reason, which *sometimes* but not always hides your messages. Not sure why. – Kraigolas Sep 09 '20 at 12:51
10

After hours of searching and trying, I found out it did not have to do with Android Studio, but that my phone didn't allow Logging. See this answer for more information.

Community
  • 1
  • 1
P.Yntema
  • 548
  • 2
  • 8
  • 28
6

Alternatively, you could use System.out.println() to show the text in logcat

Replace

Log.d("Oncreatetestlog", "onCreate() Restoring previous state");

With

System.out.println("Oncreatetestlog onCreate() Restoring previous state");
Cut7er
  • 1,189
  • 8
  • 24
Jamie Turner
  • 61
  • 1
  • 5
5

If Log.d is not showing in your Logcat just replace Log.d with Log.wtf Like this:

Replace:

Log.d("tag",""+catstr);

With:

Log.wtf("tag",""+catstr);

It Works..happy coding;)

Gaurav Lambole
  • 253
  • 3
  • 3
0

Please check in "Run" on the right side of "Debug" on the bottom of the IDE. in my case i actually did everything what they told but yet it's not working. so i checked there and i fount all the log over there. thanks

MueEZ
  • 86
  • 1
  • 4