10

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
  • 576
  • 2
  • 9
  • 29

5 Answers5

18

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

Taras Mykhalchuk
  • 829
  • 1
  • 9
  • 20
  • 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
11

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
  • 576
  • 2
  • 9
  • 29
7

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,209
  • 9
  • 24
Jamie Turner
  • 71
  • 1
  • 5
7

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
  • 273
  • 3
  • 3
  • I swear I thought this StackOverflow answer was a joke. IT IS NOT! It really did work for me. Never figured out why Log.d stopped logging for me, but this works great! – gcdev Dec 08 '22 at 20:25
1

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
  • 136
  • 1
  • 1
  • 7