Important Update
The Guide Feature will be discontinued after December 15th, 2023. Until then, you can continue to access and refer to the existing guides.
Author avatar


Log information of your app through Lonline by Dynamicloud


  • Dec 14, 2018
  • 13 Min read
  • Dec 14, 2018
  • 13 Min read


Lets get started thinking about availability

"Availability of a system is typically measured as a factor of its reliability – as reliability increases, so does availability." (Wikipedia)

Availability is very important when trying to create a reliable system. But, how do we offer that kind of system and how can we create/provide something that makes us feel confortable?

Features of a reliable system or application

  • Always available
  • Built using a complete suite of test cases
  • Contains integrated diagnostic tools
  • Has real-time monitoring
  • Restricts access from external clients
  • Logs every potential error in real time

Logging every potential error in real time

Logging your program is an important task when you're developing an app because it allows you to know more about the behavior and performance of your app. That way, you can build fixes and execute decisions whenever you find bugs in your product.

Nowdays checking log results is very difficult because logs typically reside either within a server, a virtualization, a virtual server, or a cloud service.


Lonline allows you to log your program into the cloud and is powered by the Dynamicloud service. Cloud-based logging avoids server access and disk usage. Lonline provides 6 levels of logging and 2 methods of executing reports. Its Dynamicloud service facilitates data storage and access. Furthermore, Lonline allows you to set more features, and thus track more than just text, level, and program traces.

In this guide, I will cover the following content:


Lonline has one dependendency: Dynamicloud Nodejs API

Dynamicloud also provides APIs for Java and Ruby language, so you can use Lonline in Java or Ruby programs.


You can install this module in your system using the Node Package Manager (npm) command:

npm install lonline


Lonline needs basic settings to be configured. These settings are within a "Settings" file that comes with the Lonline package.

These are the settings of Lonline:

2 * Options Documentation:
3 */
4var ops = {
5     //OPTIONAL: This is the current logger object you're using in your program.
6     //Lonline will call the same function in legacy object, for example:
7     //lonlineLogger.error("It couldn't process the data");
8     // The line above will execute the method error from legacy object passing the log
9     // and the error as follow:  legacyObject.error(log, error);
10     legacy: myOwnLogger
11     //OPTIONAL: This attribute indicates the path to load the settings, if this attribute is present all the
12     //below attributes will be skipped.
13     //This file must be a compatible json file.
14     fileName: '../setting.json',
15     //This attribute indicates the level of lonline
16     //The following table is an explanation of levels in Lonline (Descriptions from the great Java Log4j library):
17     //------------------------------------------------------------------------------------------------------------
18     //| Level      | Activated levels           | Description                                                    |
19     //------------------------------------------------------------------------------------------------------------
20     //| fatal      | Fatal                      | Designates very severe error events that will presumably lead  |
21     //|            |                            | the application to abort.                                      |
22     //------------------------------------------------------------------------------------------------------------
23     //| error      | Fatal, Error               | Designates error events that might still allow the application |
24     //|            |                            | to continue running.                                           |
25     //------------------------------------------------------------------------------------------------------------
26     //| warn       | Fatal, Error, Warn         | Designates potentially harmful situations.                     |
27     //------------------------------------------------------------------------------------------------------------
28     //| info       | Fatal, Error, Warn, Info   | Designates informational messages that highlight the progress  |
29     //|            |                            | of the application at coarse-grained level.                    |
30     //------------------------------------------------------------------------------------------------------------
31     //| debug      | Fatal, Error, Info, Warn   | Designates fine-grained informational events that are most     |
32     //|            | Debug                      | useful to debug an application.                                |
33     //------------------------------------------------------------------------------------------------------------
34     //| trace      | All levels                 | Traces the code execution between methods, lines, etc.         |
35     //------------------------------------------------------------------------------------------------------------
36     //| off        | None                       | The highest possible rank and is intended to turn off logging. |
37     //------------------------------------------------------------------------------------------------------------
38     level: 'error',
39     //Credentials for REST APIs
40     //Go to and get the API keys available in your profile
41     //If you don't have an account in Dynamicloud, visit
42     //You can easily use a social network to sign up
43     csk: 'csk#...',
44     aci: 'aci#...',
45     //This is the model identifier for test and development environment
46     //The model contains the structure to store logs into the cloud
47     //For more information about models in Dynamicloud visit
48     modelIdentifier: 000,
49     //OPTIONAL: Shows every warning like rejected request from Dynamicloud and other warnings in lonline
50     warning: true,
51     //OPTIONAL: report_limit indicates how many records lonline will execute to fetch data from Dynamicloud.
52     //If you need to increase this value, please think about the available requests per month in your account.
53     //Dynamicloud uses a limit of records per request, at this time the max records per request is 20.  So,
54     //report_limit=100 are 5 request.
55     reportLimit: 100,
56     //Send the backtrace (the ordered method calls) of the log.  If you want to avoid this sets to false
57     backtrace: true,

Lonline allows you to put the settings into a file. The file's path must be passed through the attribute fileName.

1//OPTIONAL: This attribute indicates the path to load the settings, if this attribute is present all the
2//below attributes will be skipped.
3//This file must be a compatible json file.
4fileName: "../settings.json";


2  "csk": "csk#...",
3  "aci": "aci#...",
4  "modelIdentifier": 000,
5  "backtrace": true,
6  "level": "trace"

Dynamicloud account

Lonline needs API credentials from a Dynamicloud account. These credentials allow Lonline to access your account's structure (Model). The mandatory model in your account should be composed for a model with at least three fields. For further information about models and fields in Dynamicloud, visit its documentation at Models & Fields

*Let's set up your account in Dynamicloud. Don't worry, it is very easy:**

  1. Sign up in Dynamicloud (You can use a Google, Linkedin, or Github account to speed up registration)
  2. Click on Add Field link at your Real time Dashboard. Here you need to add three fields:

a. Fields:

Field identifierField labelField commentsField typeIs a required field in form?
lonlinetextLog textContains the trace of this logTextareaYes
lonlinelevelLog levelContains the log levelComboboxYes
lonlinetraceComplete TraceContains the complete trace of the logTextareaNo

b. lonlinelevel is a combobox. You need to add the following options:


To add these options follow the steps below:

  1. Click on the Global Fields link at your Real time Dashboard
  2. In the table of fields, find the row with the identifier lonlinelevel
  3. Click on the Manage items link. An empty list of items will be shown, there click on Add new button and fill the value and text field
  4. Step number three should be executed six times: once for each one of the available levels (Fatal, Error, Warn, Info, Debug and Trace).

c. Add model

A model is the container of these fields. To add a model:

  1. Click on Add model link at your Real time Dashboard
  2. Fill the mandatory field name and set a description (Optional)
  3. Press button Create
  4. In the list of Models the Model box has a header with the model Id, copy that Id and put it in your settings.json file.
2  "modelIdentifier": "Enter_Model_Id"
The last step is to copy the API credentials (CSK and ACI keys) to put them in your settings.json file.
  1. Click on the Your name link at left top of your account
  2. Copy the CSK and ACI keys, and put them into your settings.json file.
2  "csk": "Enter_Client_Secret_Key",
3  "aci": "Enter_API_Client_Id"

At this moment you can start to log your program into the cloud.

How to use Lonline

Lonline is easy to use; one line of code logs and stores into the cloud.

Log using the six levels

1var lonline = require("lonline");
2var logger = lonline.getLogger({ fileName: "settings.json" });
4logger.trace("Calling method Y");
5logger.debug("Creating new object");"Process has finished");
7logger.warn("It could'n create this object, the process will try later.");
8logger.error("Unable to load setting file");
9logger.fatal("The app has crashed and its state is unavailable");

Additional data

Lonline allows you to log additional data. If you want to log more information (for example, whether the module in your application has executed the log), just pass a LonlineLog object with the corresponding attributes and values. Remember that these additional attributes must match with the fields in your model, so you need to add these fields to the model before logging.

To log additional information, follow the code below:

1var lonline = require("lonline");
2var logger = lonline.getLogger({ fileName: "settings.json" });
4logger.trace("Calling method Y", null /*This is the error object*/, {
5  module: "financialModule"

Execute reports

Lonline allows you to execute reports about the executed logs and count how many logs have been created so far.

1var lonline = require('lonline');
3var today = new Date();
5var fromDate = new Date(today.getFullYear(), today.getMonth() - 1, today.getDate(), 0, 0, 1, 0);
6var tomorrow = new Date(today.getFullYear(), today.getMonth(), today.getDate() + 1, 23, 59, 59, 0);
8var reporter = lonline.getReporter({fileName: './settings.json'});
9reporter.fetch(reporter.ERROR, new Date(), new Date(), function(logs) {
10    _.each(logs, function(log) {
11        console.log(log['lonlinelevel']);
12        console.log(log['lonlinetext']);
13        console.log(log['lonlinetrace']);
14        console.log(log['module']);
15        .
16        .
17        .
18        .
19    });
22reporter.count(reporter.FATAL, fromDate, tomorrow, function (count) {
23    console.log(count > 0);


Below are some common problems that arise when you configure Lonline

  1. setting.json file in the wrong Dynamicloud ModelId.
  2. setting.json file contains the wrong CSK and ACI from Dynamicloud. These are the credentials to gain access to the service, so they need to be authentic.
  3. The fields in your model don't follow the right configurations (names, values, types, etc.)

Dynamicloud has a Contact form online in case you need additional troubleshooting. See the Dynamicloud contact form.

Hopefully this guide helps you raise app efficiency through the Lonline logging method. If you found this tutorial informative, don't hesitate to hit the like button. Please leave all feedback in the comments section!