Logging

Enterprise Browser 3.3

Overview

Enterprise Browser includes a powerful logging engine, which offers administrators, developers and tech support teams the potential to access rich, multi-level data streams relating to application execution, events and failures for debugging an app and analyzing events following a crash or other failure. This guide explains how to enable logging, select logging levels, send messages to the log and to retrieve the log file. Logging for an Enterprise Browser app is controlled in the Logger section of the app's Config.xml file.

In Enterprise Browser 1.8 and higher, the automatically generated <EB_VERSION> tag stores version information in the Config.xml file, which is analyzed for logging and diagnostics purposes.


Enable Logging

Logging is hierarchical, with lower-order log-event settings overridden by higher ones. For example, the LogError setting can be overridden by any other setting, but LogUser can be superseded only by LogMemory. The list below describes each of the logger settings and is arranged in ascending order of precedence.

The five levels of log messages:

LogError - Controls logging of ERROR messages generated by an Enterprise Browser app. If set to 1, it enables error-level logging only (overridden by LogWarning).

LogWarning - Controls the logging of WARNING messages generated by an Enterprise Browser app. If set to 1, enables warning and error messages (overrides LogError setting; overridden by LogInfo).

LogInfo - Controls the logging of INFORMATION messages generated by an Enterprise Browser app. If set to 1, enables Info, Warning and Error logging (overrides LogWarning and/or LogError settings; overridden by LogUser).

LogUser - Controls logging of User, Info, Warning and Error messages from the user application (overrides LogWarning, LogError and/or LogInfo settings). Data can be logged using the Log API.

LogMemory - Controls the logging of memory usage in the system. Supports Android, WM/CE; does not apply to the Enterprise Tablet.

The <Logger> section of the Config.xml file is shown below with its default settings. To enable logging for a particular event, change the value in the event's tag to "1" as shown below for Error, Warning and Info events:


<Logger>
    <LogProtocol   value="FILE"/>
    <LogPort       value="80"/>
    <LogURI        value="file://%INSTALLDIR%/Log.txt"/>
    <LogError      value="1"/>
    <LogWarning    value="1"/>
    <LogInfo       value="1"/>
    <LogTrace      value="0"/>
    <LogUser       value="0"/>
    <LogMemory     value="0"/>
    <LogMemPeriod  value="5000"/>
    <LogMaxSize    value="5000"/>
  </Logger>

Logging Options

Enterprise Browser logging offers the following additional options:

LogProtocol - Sets the protocol (File or HTTP) over which the logging data will be sent (accepts any valid URL or fully qualified path and file name).

LogPort - The port over which the logging data will be sent when HTTP is set in LogProtocol; otherwise ignored (accepts any valid HTTP port number).

LogURI - The URL or file name and path to which logged data should be sent or saved (accepts any valid URL or fully qualified path and file name).

LogMemPeriod - Specifies the time interval (in ms) after which memory logs will be generated (accepts an integer). Supports Android and WM/CE; does not apply to the Enterprise Tablet.

LogMaxSize - Specifies the maximum allowable size (in KB) of the log file, after which no more logs will be saved (accepts an integer).


Logging Messages

For added visibility into an app, log messages can be invoked from program code. The easiest way to do this is usually to add a print statement to the segment where insight is needed. In JavaScript, this is done via the console.log() method. For instance, to gain visibility into the contents of the variable "name," try something like to the following:


var name = "firstName";
console.log("Name: " + name);

The name set by this code will be printed to the log file in the form of a line with the contents "Name: firstName." This is a useful way to determine if the data in an app is formed as expected. If the result is a null value on a variable is supposed to have data, print it to the log file to make sure it's actually getting defined.

Retrieving the Log File

Once the log contains sufficient data, it might be desirable to view the logs periodically to gain insight into what's happening in the app. The location of the log file varies depending on the platform.

Path to log file:

  • On Android devices: /sdcard/Android/data/com.zebra.mdna.enterprisebrowser/
  • On Windows devices: \Program Files\EnterpriseBrowser\log\

Note: Enterprise Browser cannot write to an external SD Card.


Related Guide: