Search code examples
javaandroidlogginglogcat

The logcat is full of other messages, is there another way of logging?


When I develop android apps, I often find logging very hard. Not very hard to log the message, but very hard to see the logged message.

Maybe because I am using an actual phone to debug, the logcat is constantly filled with messages. I can switch the severity to "Error" so that there is less messages but then I can't see my "Info" message! Now the only way I can think of is to Log.e instead of Log.i. But that doesn't really make sense!

For example, I want to display the display metrics:

Point pt = new Point ();
getWindowManager ().getDefaultDisplay ().getSize (pt);
int height = pt.y;
int width = pt.x;
Log.i ("Display Metrics", "Height: " + height);
Log.i ("Display Metrics", "Width: " + width);

I can't find the message in the logcat because the messages keep coming. I can't even post the logcat here! How am I supposed to log stuff?


Solution

  • A few tips to help you work with Logcat:

    1. You can use the tag parameter in various log methods and later on filter your Logcat for lines containing your tag only
    2. If you are having trouble with Logcat scrolling down to the bottom whenever a new message is logged, just click anywhere in the Logcat console (so on any log message).
    3. You can create a custom filter that automatically filters the log for you logcat filter
    4. Make sure you select your device and your application here: connect device