Countly has centralized logging system. This system ensures consistent logging across various components and ability to alter behavior of loggers at run time.

To use Countly logging, you need to:

  1. Instantiate a logger by calling common.log("LOGGER_NAME") where common is a api/utils/common.js module. Instead of LOGGER_NAME you need to supply your plugin name followed by plugin component name: "users" or "users:api".
  2. Call one of the logger's functions: d, i, w, e. Each function represents a distinct logging level: DEBUG, INFO, WARNING, ERROR respectively. Arguments of those functions are the same as console.log has.

Here is an example of a typical plugin:

var plugin = {},
	common = require('../../../api/utils/common.js'),
	log = common.log('flows:api'),
	plugins = require('../../pluginManager.js');

plugins.setConfigs('myPlugin', {
	someConfigurationOption: 5,

(function () {

	plugins.register('/i', function(ob){
		var params = ob.params;
		log.i('myPlugin got a request: %j', params.qstring);


Logging configuration

Main logging configuration is in Configuration section of Management menu:

Logging configuration consists of comma-separated list of logger names for each logging level. Default value is a logging level for loggers which are not listed in config. To overwrite logging level WARNING for module api and to set it to DEBUG, for instance, you'll need to replace pushly on the screenshot above with pushly, api. This will automatically enable all api:XXX loggers as well unless some of them have different log level in configuration.

Also note, that due to the fact that this configuration is not available on Countly startup, default logging configuration must be supplied to config.js as well. config.js preferences are used on startup and then get replaced by shared configuration stored in Mongodb:

var countlyConfig = {
    logging: {
        info: ["jobs"],
        default: "warning"

module.exports = countlyConfig;
Was this article helpful?
0 out of 0 found this helpful

Looking for help?