Data is King

The ingress of a data driven environment has lead to an era where mobile application development has deemed data to be the king. It is in the development and marketing of web applications that the dominance of data is getting proven every day.

For a company wanting to come up with an app, the decision is not simple. They go through months of research, trying to find out whether their app would be accepted by a certain demographic category. The inference drawn solely from research is done with the help of data, followed by gaining insights on what people in that particular category like and dislike.

For example, in the current trend, you don’t see too many display ads in apps because people dislike seeing such ads or even disruptive ads, where they have to search all over the screen for closing it. You can however think about ways to activate aspirational brand identity as it reaches out to them much more effectively.

How Logging helps Digital Marketing Business?

Through efficient data analysis, you can plan online advertising campaigns that measure in results. Each campaign will be different from the previous one launched. It is all in a test and learn framework that can be done only at the pace of a machine. You can program computers to tap in on a particular pattern by watching the trillions of advertising responses. As a mobile app development company, you can follow on these patterns to make new ad campaigns.

And once the apps are released into the market, then it all comes down to full visibility of your app. To ensure this, it is important to have accurate data concerning the metrics and events that allow you to monitor the performance of your app, understand and troubleshoot issues as and when they arise. This is where logging comes into the picture.

Logging plays a Crucial Role in Application Troubleshooting and Performance Monitoring

Though logging is not an entirely new concept, it has presently become the staple of application management and monitoring, the most attractive feature being remote monitoring. The most important advantage of logging is that you hear about issues as and when they occur, even before users themselves start realizing it.

Instant alerts would reach you so that you can resolve the problem or manage it more efficiently. Cloud services offering logging service give you the power to search your log events in real time so that you can gain immediate insight and reach a reliable resolution. Many of these services have special tools capable of instantly detecting anomalies in log entries.

For example:

Inactivity Alerts – When things don’t happen as they should, you will be alerted
Pattern-Based Alerts – where you are alerted when there are certain patterns in your logs. You can actually control how often you should be alerted and what kind of a pattern you want to be alerted about
Alerts to the Whole Support Team – Alerts are useless if they are missed. When team-wide notifications are incorporated in the monitoring tool, someone is bound to notice a pattern and get alerted.

What should we Log?

In simple words, logging is recording something to another interface. And logging plays an important role because it is a valuable tool in detecting not only different patterns to devise customer behavior, but would also be a great resource in identifying threats. All the good logging frameworks provide for different ways to describe problems:
‘Warn’, ‘Error’ and ‘Fatal’ for general information purposes and Debug purposes.

Before going into the guidelines of how to use ‘log in’ level, we can look at what should be logged. If you want a simple answer, it depends greatly on the application that you are developing. But when you are trying to analyze what went wrong with your application, then you need to go into detailed information which is possible only through logging.

Logging is, thus, a process that will keep recording application actions and state, for future perusal, into another interface, ranging from web services, email, file and so on. How it is transferred is not important, the main thing is that it is transferred.

This is because the person responsible for checking the logs will only have access to the secondary interface and not the primary one. Hence, the information recorded in the secondary interface must be accurate, timely and complete, as it would eventually become the most important link.

Logging is a Structured Approach

As mentioned earlier logging, when performed by good frameworks are perfect. The different levels of the log will be sent to the concerned people working at different specialties’, depending on their urgency. Good frameworks have the capability to filter messages according to importance. Let’s go through the general information and the debugging process in detail:

Info

The function of Info, is thus purely informational and they will be able to convey any fault or error. This is just general information that you can use when the primary interface remains inaccessible.

Examples of general information could be (1) version information of the software- it is virtually impossible to keep working on a software without even knowing its version, (2)the users, mainly who uses the software and (3) the external services (web servers, databases, etc.)used by the software.

If there is an application error, it is this information that will be used for diagnosing the error.

Warn

A bolder step after the previous (information) stage. You can also say that it is the first important step that gives the indication of any trouble. When you receive a ‘Warn’ message, it means there is some problem along the way, but that users are continuing to use your application.

For example, if there is any trouble using the external services, you can expect this message to appear, but things are not very serious because there will be a secondary service handling the issue.

Error

Things are starting to get more serious here and user experience is partially hindered. Failure level of the application has gone a notch higher as users are not able to use the app as earlier. Once again, it could be the database connection that has been affected in some way and several attributes of the app gets rendered useless, and perhaps temporarily, as those can be corrected.

Fatal

Fatal, as the name suggests shows that the level of failure has turned extremely critical. Any component that has been working as the backbone of the application has failed to perform, in which there is no option but terminate the application as a whole. Once the fatal message is registered, the users cannot use the application in anyway.

Debug

The logged messages that you see in the Debug level are targeted entirely towards the developers, and hence used mainly for debugging purposes. Though it largely depends on the application you are developing, through Debug, you can solve a number of problems concerning the application.

For example, you can rely on Debug messages to catch the existence of potential bugs in your application. The disadvantage with Debug is that it works optimally only during a particular development stage and in the case of certain applications. It segregates fine grained information that would help the developer debug the application.

The example below shows the filtering of Info messages and Debug messages, where the desired logging level is designed using the logger method setLevel(Level.X):


import org.apache.log4j.*;

public class LogClass {
   private static org.apache.log4j.Logger log = Logger.getLogger(LogClass.class);
   
   public static void main(String[] args) {
      log.setLevel(Level.WARN);

      log.trace("Trace Message!");
      log.debug("Debug Message!");
      log.info("Info Message!");
      log.warn("Warn Message!");
      log.error("Error Message!");
      log.fatal("Fatal Message!");
   }
}

Credits : Tutorialspoint

What should we be Logging?

Now that the logging information and its guidelines are out of the way, it is time to explore what should be logged in. Of course, it does depend on the nature of the application, but that’s not all. It is important to have a very detailed log when the application log is the only detailed information you can collect, but when you have other tools to monitor user activities, then the log can be a little sparse.

Irrespective of how detailed you want the logs to be, extreme caution must be exercised on the content of the message. The quality of the log is important when you are trying to diagnose a fault. Conduct a few simple tests to decide how much content you should log in. Profiling is one such option.

Logging frameworks are usually very lightweight, so you can concentrate on how to use it optimally. Even so when you log the full class path, method name, file name, line name for each log message, then you are going to be loaded with heavy CPU cycles that you probably cannot manage.

Other than that, you can choose to go for time based logging. There are cloud based services that would mine tons of data in real time, and where you will receive actionable insights to help deliver the best experience to your app users. This way you can remove application issues, slow performance and other operational issues out of the way.

The logging of data largely depends on how you use it, learning to use the framework well and not making use of its capabilities can be observed in the table below.

The example you see below was done using 1,000,000 iterations of a single test loop, where INFO logging is enabled, and DEBUG level remains disabled. This is just a single test, you will have to keep running the tests to get a stable value:

Loggly Table

Credits : Loggly

The platform from which you can log in – It doesn’t matter which OS you are using because you can remotely access the collector machine, (here, the centralized log collector). You can use a cross platform log server or any cloud based logging service to centralize your logging data.

How Logging of Data Improves your Application?

You can manage your network and application better with data logging. As mentioned earlier, data is king, so if you have detailed logs it would be good. Still it means that while logging is important, it must be handled with care.

When there is too much log information, missing out on crucial points is a serious repercussion, especially when you have to troubleshoot a problem. Logs that fill your file system could seriously affect your performance application when nobody looks at it.

While deploying an application in production, use your Info and Debug files with caution as that could also flood your file system with useless log information most of the time. In certain cases, even Warn and Error logs are also misinterpreted if they are registered too many times, making it very hard to analyze log files.

Hence, it is very important that you configure the log levels accurately and test the settings to verify there are no Debug and Info messages floating around.

Logging Mechanisms in the Following Languages:

Generally, there are two major use-cases for using loggers within your code. One is invasive logging, used when logging is part of domain logic, and the other, non-invasive logging, where instead of altering the class you want to log on, you can wrap an existing instance and configure it to track exchange between instance and the rest of the application.

For PHP

The Monolog library with its PSR-3 interface sends all your files, inboxes, databases and sockets to help build advanced logging strategies. Using Monolog would help adhere you to PHP-FIG standards, thereby enabling you to switch over to another implementation whenever you feel.
You can use the following code for basic usage:

<?php 
use Monolog\Logger;
use Monolog\Handler\StreamHandler; 

// create a log channel
$log = new Logger('name'); 
$log->pushHandler(new StreamHandler('path/to/your.log', Logger::WARNING));

// add records to the log
$log->warning('Foo');
$log->error('Bar');

Credits : GitHub

For Node.js

Node works with Winston, a multi-transport, asynchronous logging library. Winston is known for its simple logging mechanism.


var log4js = require('log4js'); 
//console log is loaded by default, so you won't normally need to do this
//log4js.loadAppender('console');
log4js.loadAppender('file');
//log4js.addAppender(log4js.appenders.console());
log4js.addAppender(log4js.appenders.file('logs/cheese.log'), 'cheese');

var logger = log4js.getLogger('cheese');
logger.setLevel('ERROR');

logger.trace('Entering cheese testing');
logger.debug('Got cheese.');
logger.info('Cheese is Gouda.');
logger.warn('Cheese is quite smelly.');
logger.error('Cheese is too ripe!');
logger.fatal('Cheese was breeding ground for listeria.');

}

Output


[2010-01-17 11:43:37.987] [ERROR] cheese - Cheese is too ripe!
[2010-01-17 11:43:37.990] [FATAL] cheese - Cheese was breeding ground for listeria.

Credits : GitHub

For .NET

The code snippet below will show you how to configure log 4 net in all your applications, once you download it. As mentioned earlier, you can decide on the five main log levels – Info (the lowest priority), Debug, Error, Warn, and Fatal (highest priority) with this.

1   <configSections>
2       <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
3     </configSections>
4    <log4net>
5       <appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender,log4net">
6         <file value="Logs/Notification" />
7         <appendToFile value="true" />
8         <rollingStyle value="Date" />
9         <StaticLogFileName value="false"/>
10        <datePattern value="-dd-MMM-yy'.log'" />
11        <!--Roll every Day-->
12        <maxSizeRollBackups value="-1" />
13        <!--Infinite backups-->
14        <maximumFileSize value="2MB" />
15        <!--Maximum size of 1 file-->
16        <layout type="log4net.Layout.PatternLayout">
17          <!-- http://logging.apache.org/log4net /release/sdk/log4net.Layout.PatternLayout.html -->
18          <conversionPattern value="%date{dd-MMM-yy, HH:mm:ss} - %5level [%thread] - %message%newline " />
19        </layout>
20      </appender>
21      <appender name="SmtpAppender" type="log4net.Appender.SmtpAppender">
22        <to value="EMAIL" />
23        <from value="EMAIL" />
24        <subject value="Error in Component" />
25        <smtpHost value="SMTP SERVER" />
26        <bufferSize value="512" />
27        <lossy value="true" />
28        <evaluator type="log4net.Core.LevelEvaluator">
29          <threshold value="FATAL"/>
30        </evaluator>
31        <layout type="log4net.Layout.PatternLayout">
32          <conversionPattern value="%newline%5level [%thread] [%file]- %message%newline " />
33        </layout>
34      </appender>
35      <root>
36        <!-- Ascending Priority: Debug,Info,Warn,Error,Fatal,ALL -->
37        <priority value="ALL" />
38        <appender-ref ref="RollingLogFileAppender" />
39        <appender-ref ref="SmtpAppender" />
40      </root>
41    </log4net>

Credits : Jitendra Zaa

How Third Party Apps use Our Data

It is an eerie feeling when you feel someone is watching you or looking over your shoulder. But once you get into the Internet, you are exposing a lot of your information online. People then use this information to sell their products and services.

Take the example of Facebook. When Facebook was first launched, it was a rosy world where friends can meet with long lost friends and family bonds together, but as the years went by, the benefits of advertising through Facebook was discovered and pursued with vigor. Now you can use Facebook to tap into your target segment by listening to their likes and dislikes and release something they would accept.

Third party companies can use your data in the following ways:
When a user accesses your app – When a user signs up with your website and starts making use of your app, then third party apps can ask your permission to integrate with the user’s profile and track them. In Facebook, when you accept a game, the third-party can pull out your personal information and your posts to know more about you.

When a user logs into your website/app – When you have a platform like Facebook, third party apps will request to connect with you, so when a user visits their site, they give the user the option “Connect with Facebook”. In such cases, it is the user himself who is giving the third party app the permission.

Monitoring friends apps – Even if your user has not downloaded any app, Facebook allows their monitoring through friends’ apps. So if a user’s friend has installed a particular app, then that allows the third party to see the friend as well.

How Google keeps Your Data Safe

Security of data cannot be compromised at any cost, which is why cloud service providers take a staunch oath that it will be protected at all costs. Depending on the service used, you can expect the highest standards for keeping your personal and financial information safe.

Google for example, has the world’s most advanced security infrastructure to ensure your data is safe while in transit. Even when you log in from a remote device, you can be assured that this data would be safe. This proves that Google possesses one of the largest and most reliable secure clouds of all.

Each of Google’s employees are whetted and thoroughly scrutinized before they are even hired. You can visit YouTube for a thorough explanation of how Google data center keeps the data locked down safely.

Google protects your data by splitting it up and storing them in multiple files in multiple machines. The file names are also separate so it is not possible to match them to the owner, and each server disk has millions of files in them.

Google obfuscates the data with complex encryption files that cannot be copied. The data itself is made to look confusing and are distorted so it is not possible to discern anything from them. The hardware, i.e. the servers themselves are saved on custom built Linux software stack. The disc containing the data are neatly labeled and organized and if a disc gets warped, it goes through a disc shredder.

How to Monitor and Enhance Your App using Data!

If you are investing time and money to collect data, perform data analytics, then you must invest in data monitoring as well. This is imperative to releasing a successful mobile application. The hours spent in planning will see fruition when you make optimal use of data. Through proper app analytics, you can monitor usage data and measure user behavior.

If, for some reason your app is not performing as you envisaged, then make use of this data analytics to find out what’s wrong. It is also crucial to have up-to-date app date, which is why cloud providers always send real time reports so clients can monitor the right metrics and meet their app goals. You can also focus on specific engagement data to make use of data that’s really useful and make data driven optimization decisions.

What to Do with the Logs being Collected

Cloud services provide you with data and log reports that would help you take crucial business decisions. Irrespective of the volume of data that is coming in, providers like Splunk, Logstash and Graylog would help you draw intelligent insights.

Now what would you do with these reports? It is imperative that you decipher these log reports correctly. Cloud based log providers send these reports to clients like you to help build your own reports and analysis. You can tune their services to accommodate all your needs and even extend them as per the changing market requirements.

The log reports that reach you would help you distinguish between data that is not useful and data that you need collaborate effectively. You can segregate the general information messages and the debug messages and tag the ones that need immediate action. Thus, it is possible to use these log reports to sort, filter and analyze the data by following the status of different files.

In Closing

App log events can thus play a major role in revealing Error rates, trends in mobile usage, app performance and usage. Hiring the services of reliable cloud based services would allow you to monitor your app’s performance and track issues before they turn serious.

App log events would also give you trustworthy insights and deep visibility on the trends in app usage, configuration compatibility and end user experience, so you can make important business decisions.

Interested in creating an app that will be a hit with your target users? We’re here to help.
Contact Us Today!

Free Whitepaper: Top 9 Mobile App Development Best Practices