Accepted answer

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.


i use below log format for print my content in logcat

log.e("msg","what you have to print");


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.


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.


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..).

Related Query

More Query from same tag