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

  December 16, 2015

Logs are an 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 a 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 our 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 a very easy and straightforward way to push your data, stack traces with a 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 Bitbar Testing

Okay, let’s start with a basic example for Android real-time data logging. I’ll be using Loggly as an example.

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 the 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 text 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 the manual testing service at Bitbar Testing. 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.


All right, that’s all to set up a data logging for your mobile app in real time!

Happy Logging!