I am using java logger for java projects.But now I want logs in Android.So how to carry out it.Alos I need to maiantain logs for warnings ,errors,informations in a file with serial logs.
-
2possible duplicate of [How do I write outputs to the Log in Android?](http://stackoverflow.com/questions/2364811/how-do-i-write-outputs-to-the-log-in-android) – Cristik Apr 21 '15 at 12:50
1 Answers
Use android.util.Log
and use methods like:
Log.v(), Log.d(), Log.i(), Log.w() and Log.e()
There are five levels of logs you can use in your application, for the most verbose to the least verbose :
- Verbose:For extra information messages that are only compiled in a debug application, but never included in a release application.
- Debug: For debug log messages that are always compiled, but stripped at runtime in a release application.
- Info: For an information in the logs that will be written in debug and release.
- Warning: For a warning in the logs that will be written in debug and release.
- Error: For an error in the logs that will be written in debug and release.
A log message includes a tag identifying a
group of messages and the message.
By default the log level of all tags
is Info, which means than messages
that are of level Debug and Verbose should never shown
unless the setprop command is used
to change the log level.
So, to write a verbose message to the log, you should call the isLoggable
method
to check if the message can be logged, and call the logging method :
if (!Log.isLoggable(logMessageTag, Log.Verbose))
Log.v("MyApplicationTag", logMessage);
And to show the Debug and Verbose log message for a specific tag, run the setprop command while your device is plugged in. If you reboot the device you will have to run the command again.
adb shell setprop log.tag.MyApplicationTag VERBOSE
Hope this solved your question.
For more reference :http://www.codelearn.org/android-tutorial/android-log
Upvote if you found it helpful.

- 7,282
- 3
- 30
- 55