How to output messages to the Eclipse console when developing for Android

AndroidEclipse

Android Problem Overview


How can I print messages (like a flag) to the Eclipse console (or log) when developing and debugging an Android app

Android Solutions


Solution 1 - Android

Rather than trying to output to the console, Log will output to LogCat which you can find in Eclipse by going to: Window->Show View->Other…->Android->LogCat

Have a look at the reference for Log.

The benefits of using LogCat are that you can print different colours depending on your log type, e.g.: Log.d prints blue, Log.e prints orange. Also you can filter by log tag, log message, process id and/or by application name. This is really useful when you just want to see your app's logs and keep the other system stuff separate.

Solution 2 - Android

Log.v("blah", "blah blah");

You need to add the android Log view in eclipse to see them. There are also other methods depending on the severity of the message (error, verbose, warning, etc..).

Solution 3 - Android

System.out.println() also outputs to LogCat. The benefit of using good old System.out.println() is that you can print an object like System.out.println(object) to the console if you need to check if a variable is initialized or not.

Log.d, Log.v, Log.w etc methods only allow you to print strings to the console and not objects. To circumvent this (if you desire), you must use String.format.

Solution 4 - Android

I use Log.d method also please import import android.util.Log;

Log.d("TAG", "Message");

But please keep in mind that, when you want to see the debug messages then don't use Run As rather use "Debug As" then select Android Application. Otherwise you'll not see the debug messages.

Solution 5 - Android

i use below log format for print my content in logCat

Log.e("Msg","What you have to print");

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionEmanuil RusevView Question on Stackoverflow
Solution 1 - Androidm6ttView Answer on Stackoverflow
Solution 2 - AndroidAlexView Answer on Stackoverflow
Solution 3 - AndroidTirthaView Answer on Stackoverflow
Solution 4 - AndroidMahmud AhsanView Answer on Stackoverflow
Solution 5 - AndroidMadhuView Answer on Stackoverflow