3

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

2
  • 1
    developer.android.com/reference/android/util/Log.html.API for sending log output. Generally, use the Log.v() Log.d() Log.i() Log.w() and Log.e() methods. Commented Jul 30, 2013 at 20:00
  • can everyone chill? This was a legitimate question. I had already tried the various log.letter() methods and the issue was that logcat was not showing. A simple google did not resolve that which is why I posted it here Commented Jul 31, 2013 at 14:21

2 Answers 2

4

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/

Sign up to request clarification or add additional context in comments.

Comments

3

Use:

Log.d("YourClassName", "Your message");

You don't have to put your class name but its common practice to. Actually most people define a final TAG string and use it:

public static final String TAG = "YourClassName";
Log.d(TAG, "Your Message");

Make sure to turn the LogCat on in Eclipse from the menu bar by pressing Window -> show view -> other ->android ->LogCat

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.