Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how do I write to console from android using eclipse

I am sure this question has been asked before but I cannot find it.

I am trying to print some simple statements during the runtime of my application. When writing a normal java application I just do

System.out.println("message");

and for iOS I do

NSLog(@"message");

I have looked around but can't find a simple solution for android? Is it possible that I have a setting misplaced in eclipse? What is the standard code used for this and where would it usually appear within eclipse

like image 263
Ben Avatar asked Aug 17 '26 13:08

Ben


1 Answers

Use the the Log class.

For your purposes I'd suggest you use the following:

Log.d("className", "message");

className lets you distinguish from which class the message is coming. message is the message you want to output into the console.

Your log will appear in the LogCat view, which is located under: Window > show view > other > Android > LogCat

You can also set filters to only see certain logs that you make. You can also log according to priority, eg errors or warnings.

For more info look at this: http://www.vogella.com/articles/AndroidLogging/

like image 84
Luke Taylor Avatar answered Aug 19 '26 02:08

Luke Taylor



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!