Backendless Logging facilitates submission of client application messages through the Logging API from the mobile device client to the Backendless server. Messages can be any debugging, informational, or diagnostic information the client developer chooses to include. The diagram below illustrates main concepts involved in Backendless logging:
Log Files and Policy¶
The logging service writes log messages received from the client app to files in the /logging directory located in the Backendless File storage allocated for your Backendless backend. The files can be viewed and managed (archived or deleted) using the Files screen of the Backendless Console.
Log File Policy sets the policy for how files are created and written. There are two file creation policies supported by Backendless:
Date-based Logging writes log messages received from the client applications to a file named after the current date. New log files are created at or after midnight on that new date. Date format used in the file name is:
Fixed file size logging writes log messages to a file until it reaches the maximum size-limit configured in the Backendless console. The file name pattern is
To set and configure a log policy, use the Manage > Log Management section in the Backendless console.
A logger is an object in the client application that submits log messages to the backend. Every logger is identified by a unique name. The name should be a meaningful indicator of the origin of the messages delivered to the server by the logger. (It could be the name of the class which generates the log messages or the name of the UI screen.) This way, a logger is recognized by the backend as soon as it receives a log message.
The log levels in the Backendless API are adopted from the Log4J logging framework. Every log messages submitted to Backendless using the Logging API must have a log level assign to it. For all API implementations in the Backendless client SDKs, the log level is assigned implicitly through the method used to log a message. The log level is assigned explicitly with the REST API.
The log levels are ordered in a hierarchy on the server-side. This is done to enable log message filtering in order to minimize or maximize the volume of logging information which ends up in the log files. This order of the log levels in the hierarchy cannot be changed. The table below shows the log level hierarchy in descending order.
The server-side can be configured to accept log messages up to the specified log level. Once a log level is set, any message at that level or the ones below is written to the log file. The table below describes the hierarchy in greater detail:
|Table: Log Levels in Hierarchical Order
||Log Levels Captured
||Collects messages from all log levels.
||TRACE, DEBUG, INFO, WARN, ERROR, FATAL
||Provides verbose information from all log levels. Useful for system and application developers.
||TRACE, DEBUG, INFO, WARN, ERROR, FATAL
||Provides support to help the developer debug the application.
||DEBUG, INFO, WARN, ERROR, FATAL
||Provides progress and state information for the end user.
||INFO, WARN, ERROR, FATAL
||Provides a warning message to the end user about an unexpected event.
||WARN, ERROR, FATAL
||Provides information about a serious error that could result in an unstable state.
||A message at this level indicates unexpected application termination.
||Ignores all log messages.
The Backendless console provides a graphical interface to manage the filtering. An application may have two levels of filters: application-wide log level and an individual log level assigned to a logger.
Application-Wide Log Level¶
For the purposes of troubleshooting and other reasons, the client developer can set an Application-Wide (app-wide) Log Level. The app-wide log level takes precedence over the individual log levels.
The app-wide log level feature sets the log level for the entire application. App-wide and logger specific levels function the same way, except app-wide is for all loggers. It takes precedence and overrides any individual logger maximum log level. Application-wide log level can be set at Manage > Log Management and is applied immediately.
Messages matching the specified app-wide level or one below in the hierarchy is written to the log file; all others are ignored. Since log levels are ordered in a hierarchy, Backendless enforces an app-wide log level, which designates the maximum acceptable log level for messages arriving from the clients.
Frank, a developer, added several loggers to his application. When he received calls from customer support, Frank needed to increase the amount of logging information received and logged from the running app. He went to the Backendless console Manage > Log Management menu. He set the application-wide log level to DEBUG. His first logger in the list of loggers was already set to WARN.
When Frank began investigating the issues, he found the first log had only WARN level messages, though the app-wide log level was set to DEBUG.
SOLUTION: Frank needed to set the application-wide log level to DEBUG and the logger-specific level to DEBUG. The two levels should be equal to capture messages that match the app-wide level.
Log File Management
The Logging API output is available in flat text format files. The files are available for viewing in the console under the Manage and Files menus. The log files can be downloaded from Manage > Log Management.