Customize PHP SDK logger
Customize log information from the Optimizely Feature Experimentation PHP SDK for debugging experiments.
The logger captures details about your experiments, making it easier for you to debug them. You can customize where the log information is stored and choose the types of data you want to track.
The PHP SDK comes with a default Logger
implementation. To configure the log level threshold, pass the log level as an argument to the DefaultLogger
constructor.
use Monolog\Logger;
use Optimizely\Logger\DefaultLogger;
/**
* To set a log level choose one of the following:
*
* INFO: Logger.INFO
* DEBUG: Logger.DEBUG
* WARNING: Logger.WARNING
* ERROR: Logger.ERROR
* CRITICAL: Logger.CRITICAL
*
* To define a different minimum logging level pass it in during initialization
* The example below shows a minimum logging level of WARNING and outputs
* to standard out
*/
$optimizelyClient = new Optimizely($datafile, null, new
DefaultLogger(Logger::WARNING, "stdout"));
Pass in a custom logger for your Optimizely client for finer control over your SDK configuration in a production environment. A custom logger is an instance of a class that implements LoggerInterface
Log levels
The following list shows the log levels for the Ruby SDK.
- CRITICAL – Logs events that cause the app to crash.
- ERROR – Logs events that prevent feature flags from working properly, such as an invalid data file during initialization or incorrect feature keys. These issues require user intervention to fix.
- WARN – Logs events that do not prevent feature flags from working properly but may cause unexpected results, such as future API deprecation, improper logger or error handler settings, and nil values from getters.
- INFO – Logs key events to illustrate the lifecycle of an API call, such as when a decision or tracking starts and succeeds.
- DEBUG – Logs extra information related to errors that aid Optimizely in debugging, like when a feature flag is not running or a user is not included in a rollout.
Updated 12 days ago