Dev guideAPI Reference
Dev guideAPI ReferenceUser GuideGitHubNuGetDev CommunitySubmit a ticketLog In
GitHubNuGetDev CommunitySubmit a ticket

Customize the GO SDK logger

How to customize the log information about experiments coming from the Optimizely Feature Experimentation Go SDK to help with debugging.

The logger logs information about your experiments to help you with debugging. You can customize where log information is sent and what kind of information is tracked.

The default logger in the Go SDK logs to STDOUT. If you want to disable or customize the logger, you can provide an implementation of the OptimizelyLogConsumer interface.

Custom logger implementation in the SDK

import "" // for v2: ""

type CustomLogger struct {

func (l *CustomLogger) Log(level logging.LogLevel, message string, fields map[string]interface{}) {

func (l *CustomLogger) SetLogLevel(level logging.LogLevel) {

customLogger := New(CustomLogger)


Setting the log level

You can also change the default log level from INFO to any of the other log levels.

import "" // for v2: ""

// Set log level to Debug

Log levels

The table below lists the log levels for the Go SDK.

Log LevelExplanation
LogLevelErrorEvents that prevent feature flags from functioning correctly (for example, invalid datafile in initialization and invalid flag keys) are logged. The user can take action to correct.
LogLevelWarningEvents that don't prevent feature flags from functioning correctly, but can have unexpected outcomes (for example, future API deprecation, logger or error handler are not set properly, and nil values from getters) are logged.
LogLevelInfoEvents of significance (for example, decision started, decision succeeded, tracking started, and tracking succeeded) are logged. This is helpful in showing the lifecycle of an API call.
LogLevelDebugAny information related to errors that can help us debug the issue (for example, the feature flag is not running, user is not included in the flag rule) are logged.

Source files

The language/platform source files containing the implementation for Go is client.go.