Reputation: 1834
I have seen like a million different log functions , like log.i
, log.v
, log.d
.
I just want to output a simple string on the log some times in my code to see if everything is working ok for debugging.
What is the clean way to do that?
Upvotes: 1
Views: 243
Reputation: 506
@donparalias great question
The Most easiest way:
public static final String LOG_TAG = "Facebook";
public void onFacebookError(FacebookError error)
{
Log.i(Facebook.LOG_TAG, "LoginListener onFacebookError " + error);
}
You can use one or all of these:
Log.d("tag","string"); :: Debug
Log.v("tag","string"); :: Verbose
Log.e("tag","string"); :: Error
Log.i("tag","string"); :: Info
Upvotes: 2
Reputation: 41129
When you change the letters after log.
you are basically setting the severity of this log record:
I => Info
V => Verbose
D => Debug
E => Error
Take a look at this picture for all the different kinds of log records:
So use .d
for simple debugging records like this:
Log.d (TAG, "the message you want to out put");
While I always set the TAG
at the begging of the class like this:
static final String TAG = YouCurrentActivity.class.getSimpleName();
Upvotes: 2
Reputation: 2351
there are different type of log.
I = Info
V = Verbose
D = Debug
E = Error
Example:
Log.d("tag","the string youd like");
Log.v("tag","the string youd like");
Log.e("tag","the string youd like");
Log.i("tag","the string youd like");
Upvotes: 1
Reputation: 8856
example
String TAG = "value of i = ";
for(int i = 0; i<=10 i++)
{
Log.i(TAG, i+"");
}
this will print the 10 numbers in your log.i (info)
.
log.d
is for debug
log.e
is for error
and so on. here is a link to study more about log
Upvotes: 3
Reputation: 7114
Log.d("tag","the string youd like");
log.d is for the debug list of LogCat
Upvotes: 2
Reputation: 1510
You can use Log to track the logs in your application code.
Log API is for sending log output.
Generally, use the Log.v() Log.d() Log.i() Log.w() and Log.e() methods.
The order in terms of verbosity(wordiness), from least to most is ERROR, WARN, INFO, DEBUG, VERBOSE. Otherwise more or less they are same.
Verbose should never be compiled into an application except during development.
Debug logs are compiled in but stripped at runtime.
Error, warning and info logs are always kept.
Upvotes: 5