Difference between log methods

Go To StackoverFlow.com

5

I am new in android and i print log-cat using:

Log.w("Tag", "String text");

and log text print but after searching for a time i find some more way to print logcat like:

Log.v() 
Log.d()

and now i am confuse in these methods.

Which is the best method for print log-cat and how may method for print lagcat and also what is the main difference between them?

2012-04-04 06:28
by Pari
you should first read android documentation carefully before asking question here...http://developer.android.com/reference/android/util/Log.htm - himanshu 2012-04-04 06:31
There is an excellent article on that http://source.android.com/source/code-style.html#log-sparingly The link posted by himanshu isn't great help as well as his behavior towards newcomers on SE - OneWorld 2013-06-20 21:18


11

commonly used Log methods are five :

Log.v () VERBOSE

Log.d () DEBUG

Log.i () INFO

Log.w () WARN

Log.e () ERROR

1: Log.v - debugging color black , and any messages will be output, where v represents the verbose verbose mean, usually is Log.v ("", "");

2: Log.d - the output color is blue , the only output debug debugging meaning, but he would output the upper filter up through of DDMS Logcat label to select.

3: Log.i - output color is green , general tips, news information, it does not the output Log.v Log.d information, but will display the information of i, w and e

4: Log.w - mean orange , can be seen as a warning The warning, in general we need to optimize the Android code, and will output it after Log.e.

5: Log.e - is red , you can think of error error here only to show the red error message, these errors we need careful analysis.

For more information:

http://developer.android.com/guide/developing/debugging/debugging-log.html

2012-04-04 06:36
by ρяσѕρєя K
And even more information: http://source.android.com/source/code-style.html#log-sparingl - OneWorld 2013-06-20 21:22
don't forget Log.wtf() outputs red. - iwrestledabearonce 2016-06-07 12:53


5

The various single-letter methods indicate the severity of the log message. Subsequently, you can filter log messages based on both the tag and the severity, and prevent lesser-severity messages from being shown in your released application (for example).

For more information:

http://developer.android.com/guide/developing/debugging/debugging-log.html

2012-04-04 06:30
by Jason LeBrun


1

There is a difference in severity;

Log.e() will simply log an error to the log with priority ERROR.

Generally, use the Log.v() Log.d() Log.i() Log.w() and Log.e() methods.

The order in terms of verbosity, from least to most is ERROR, WARN, INFO, DEBUG, VERBOSE. 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.

2012-04-04 06:36
by Chirag


0

int ASSERT Priority constant for the println method.
int DEBUG Priority constant for the println method; use Log.d.
int ERROR Priority constant for the println method; use Log.e.
int INFO Priority constant for the println method; use Log.i.
int VERBOSE Priority constant for the println method; use Log.v.
int WARN Priority constant for the println method; use Log.w.
2014-06-16 09:29
by Rajat Deep Singh
Mind to add some words of explanation - Fantômas 2014-06-16 09:50
Ads