Home Tutorials Training Consulting Products Books Company Donate Contact us

NOW Hiring

Quick links


This tutorial describes how to create and view log statements in Android applications.

1. Logging in Android

1.1. The log system of Android

The Android system uses a centralized system for all logs. The application programmer can also write custom log messages. The tooling to develop Android applications allows you to define filters for the log statements you are interested in.

1.2. Create log statements

To write log statements, you use use the android.util.Log class with the following methods:

  • Log.v()

  • Log.d()

  • Log.i()

  • Log.w()

  • Log.e()

  • Log.wtf()

They are sorted by relevance with Log.i() being the least important one. The first parameter of these methods is the category and the second is the message.

Typically you create a Constants interface in your Android application and provide your log category as a field.

// package declaration left out, use your application package

public interface Constants {
    String LOG = "com.vogella.testapp";

Android advises that a deployed application should not contain logging code. The Android development tools provide the BuildConfig.DEBUG flag for this purpose. This flag will be automatically set to false if you export the Android application for deployment. During development it will be set to true, therefore allowing you to see your logging statements during development.

The following example show how to write an error log message.

if (BuildConfig.DEBUG) {
    Log.e(Constants.TAG, "onCreate called");

1.3. Viewing log messages

2. About this website

Nothing listed.

3.1. vogella GmbH training and consulting support


The vogella company provides comprehensive training and education services from experts in the areas of Eclipse RCP, Android, Git, Java, Gradle and Spring. We offer both public and inhouse training. Whichever course you decide to take, you are guaranteed to experience what many before you refer to as “The best IT class I have ever attended”.

The vogella company offers expert consulting services, development support and coaching. Our customers range from Fortune 100 corporations to individual developers.

Copyright © 2012-2017 vogella GmbH. Free use of the software examples is granted under the terms of the EPL License. This tutorial is published under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Germany license.

See Licence.