+

Search Tips   |   Advanced Search

Log package whitelist and blacklist

We can associate a set of log messages with a specific part of the application.

Add packages to the whitelist to include the packages in logging:

Associate a log message with a package, and log a message. To exclude packages from logging (blacklist), exclude them from the filter object:

var JSONSTORE_PKG = 'wl.jsonstore';
WL.Logger.info('Hey!'); // Ignored.
WL.Logger.ctx({pkg: JSONSTORE_PKG}).info('JSONStore started');
// JSONStore started.
WL.Logger.ctx({pkg: JSONSTORE_PKG}).warn('JSONStore finished executing find.');
// JSONStore finished executing find.
WL.Logger.ctx({pkg: 'wl.analytics'}).warn('Hello.'); // Ignored.

We can list the packages that are on the whitelist or the blacklist:

WL.Logger.status();
//{ enabled : true, stringify: true, whitelist : [], blacklist : [], level : [], pkg : '', tag: {level: false, pkg: true}, android: false }

The list of keys returned match the options we can pass to WL.Logger.config.


Parent topic: Configure the MobileFirst Logger