Archive for 'Log Message'

Logging Options in Android applications.

The Android SDK includes a useful logging utility class called android.util.Log. Logging messages are categorized by severity, with errors being the most severe, then warnings, informational messages, debug messages and verbose messages being the least severe. Each type of logging message has its own method. Simply call the method and a log message is created. The message types, and their related method calls are:


  • The Log.e() method is used to log errors.
  • The Log.w() method is used to log warnings.
  • The Log.i() method is used to log informational messages.
  • The Log.d() method is used to log debug messages.
  • The Log.v() method is used to log verbose messages.
  • The method is used to log terrible failures that should never happen.



    Log.i(TAG, ”Informational message!”);  


    The first parameter of each Log method is a string called a tag. Common practice is to define a global static string to represent the overall application or the specific activity within the application such that log filters can be created to limit the log output to specific data. For example, you could define a string called TAG, as follows:

    private static final String TAG = ”MyTAG”;  


    Now anytime you use a Log method, you supply this tag. An informational logging message might look like this:


    You can also pass a Throwable object, usually on Exception, that will allow the Log to print a stack trace or other useful information.


    • try {  
    • // …  
    • catch (Exception exception) {  
    •     Log.e(TAG, ”An Exception Encountered. Application Exits.”, exception);  
    • }  



Android: Printing Messages to a Log File

During Android application development it is handy to be able to print debug messages to the log file without interrupting the application while it is running.

Start the log viewer that comes with the Androi SDK. Come to command prompt in Windows and cd \android\tools

You will see this window.

Now from your Android application you can send log messages like this.

Log.e(this.toString(), “Test log message” );//+ err.toString()

For more details..

We Can Build Your App for You. Lets Get Started !