How to Do Real-Time Data Logging for Mobile Apps Running on Cloud

Bitbar, the mobile devops company. Logo, large

Dear Testdroiders,

Logs are essential part of understanding how apps behave on different OS and device platforms. By default, both Android and iOS are pushing lots of different relevant data (and sometimes just everything) to logs. Developers can also easily add and write custom log messages or just push the data in logs for later inspection.

As execution of apps with test automation produces tons of data, and especially when tests are executed simultaneously on variety of devices, the real-time logging  can be challenging. However, this is all possible and very easy to adopt while having your app and test running on devices on a cloud service.


For instance, some of Testdroid Cloud users are using Loggly’s Logback extension to push all relevant log data to their cloud service using HTTP/HTTPS Event API. There are similar services available, but Loggly’s service is really nice and provides very easy and straightforward way to push your data, stacktraces with properly formatted timestamp, method, class and so on to their service. As this gives you a way to monitor data flow in real time, this kind of combination can reveal what really matters and what areas you should focus on your app to get fixed.

Log and Review Android App Data in Real Time on Testdroid Cloud

Okay, let’s start with a basic example for Android real-time data logging. I’ll be using Loggly as an example, so if you don’t have an account there you can create a free account here.

Step #1: Add Logback extension to your App

First, take a look at this Github repository for Logback extension for your app and test APK. We actually recommend that you include all these changes in your instrumentation APK (and not in your actual application APK).

In case you are using Maven you can find the code snippets for other package managers. Next, add the following lines of code into dependency section of your pom.xml file:


Execute mvn to install the extension:

mvn clean install

If you are using Android Studio and Gradle, you can simply add this in your pom.xml file:


Step #2: Configure the Logback extension

Next, configure Logback with your TOKEN and you can use the following code snippet as a basis.

First, create or open (if the file exists) logback.xml configuration file and add the LogglyAppender. This example pattern will parse the Java log in Loggly:

<configuration debug="true">
   <appender name="loggly" class="ch.qos.logback.ext.loggly.LogglyAppender">
       <pattern>%d{"ISO8601", UTC}  %p %t %c{0}.%M - %m%n</pattern>
   <root level="info">
       <appender-ref ref="loggly" />

Replace TOKEN with your token from the Loggly setup page.

Step #3: Add Code for Logging and Test Connection

Add code to construct a SLF4J Logger:

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
final static Logger logger = LoggerFactory.getLogger();
..."{"message" : "Test Log Entry from Your App."}");

Now, you can run your app and it will send a test message/event to Loggly service. You should see this showing up at Loggly dashboard:

message: Test Log Entry from Your App.

Another good alternative for manual remote data logging is Testdroid Cloud Interactive feature. In addition to log data, you’ll also get other relevant info (e.g. screenshots) while you are running the app through on any of our devices. If you want to try it out, please take a look at it here.

Screen Shot 2015-12-16 at 3.13.30 PM

Allright, that’s all to setup a data logging for your mobile app in real time!

Happy Logging!