Configure the Logger

Every backend application relies on some kind of logs to debug it. The VWO SDK logger logs information about your running campaigns to help you with debugging. You can customize what kind of logs you need and where to send these, that is, you can write your own logger implementation to write the logs on some file, database, or some third-party logging service.

📘

Note

For the production environment, we recommend that you pass in your custom logger implementation while creating a VWO client instance.

Log Levels

Log LevelDescription
ERROR The events that prevent campaigns from functioning properly (for example, invalid settingsFile while initializing the VWO SDK, invalid campaign keys, or goal identifiers) are logged.
WARNING The events that don't prevent campaigns from functioning correctly, but can have unexpected outcomes (for example, future API deprecation) are logged.
INFO The events which are useful and provide a certain level of information (for example, activate started, bucket value assigned, part of a campaign, tracking user, conversion succeeded, and others) are logged. This depicts the flow of the API method used.
DEBUG Any kind of useful information that can help VWO debug the issue in case of unexpected behavior (for example, a user is not in a campaign, bucket value assigned, hash value assigned, and stored User Storage Service used, and others) are logged.

To filter these log levels while writing your own logger implementation, use the Enum provided to you by VWO SDKs.

import vwo
from vwo import LOG_LEVELS

# debug level
log_debug_level = LOG_LEVELS.DEBUG

# info level
log_info_level = LOG_LEVELS.INFO

# warn level
log_warn_level = LOG_LEVELS.WARNING

# error level
log_error_level = LOG_LEVELS.ERROR

See the code example below on how to use these appropriately.

Example

import vwo
from vwo import logger

settings_file = vwo.get_settings_file(account_id, sdk_key)

# Only update the log level
custom_logger = logger.DefaultLogger(logger.DEBUG)
vwo_client_instance = vwo.VWO(settings_file, logger = custom_logger)

# Or override the custom logger method to handle logs
# i.e Send them in file or store them in database or push them into third-part service

class CustomLogger:
   def log(self, level, message):
      print(level, message)
      # ...write to file or database or integrate with any third-party service

vwo_client_instance = vwo.VWO(settings_file, logger = CustomLogger())