Introducing Sync Gateway’s logging functionality and options

    Sync Gateway’s Continuous Logging feature delivers flexible log generation and retention, without compromising the availability of diagnostic information necessary to provide effective support and maintence .

    Log Levels

    Sync Gateway logs at one (or more) of six defined log levels: none; error; warn; info; debug and trace.

    You can set individual retention policies for each log level, with logs for each level being written to separate files.

    Set log levels in your configuration file (see the logging.$level reference).

    Log levels are additive, so if you enable info level, warn and error logs are also enabled.

    The configurable log levels comprise (ordered from least verbose, to most):

    Log Level Appearance Description



    Disables log output



    Displays errors that need urgent attention



    Displays warnings that need some attention



    Displays information about normal operations that don’t need attention



    Displays verbose output that might be useful when debugging



    Displays extremely verbose output that might be useful when debugging

    Log Keys

    Log keys provide fine-grained control over the information to be logged. By default, only HTTP is enabled, other available keys include: Auth; Bucket; CRUD; DCP and Import.

    See the logging.console.log_level property reference for a comprehensive list of available keys.

    Console Log Output

    You can configure console logging independently, providing additional flexibility, without impacting the continuous logging output. For example, System administrators running Sync Gateway at the console may:

    • tweak log level and Log Keys to suit their needs,

    • filter console output by log levels and log keys

    • set a color for log output based on log level if logging.console.color_enabled is set to true

      This setting is always disabled on Windows for compatibility reasons.

    Log File Outputs

    Log files are intended for the use of Couchbase Support. If you require special log handling then use the console log output stream.

    Use SGCollect Info to collect diagnostic log data for analysis by Couchbase Support.

    The log files are split by log level, with a guaranteed retention period for each.

    Log File Default enabled Default max_age Minimum max_age



    360 Days

    180 Days



    180 Days

    90 Days



    6 Days

    3 Days



    2 Days

    1 Day

    Each log level and its parameters are described in the logging.$level property reference.

    Output Redirection

    Address specialized logging requirements, such as centralized logging, by redirecting the console log output to a file. Then you can apply your own log collection mechanism to feed that data elsewhere.

    Example 1. Redirect console log output
    # Start Sync Gateway and redirect console output to a file
    ./sync-gateway > my_sg_logs.txt 2>&1
    # Start log collection to send to a centralized log aggregator.
    logcollector my_sg_logs.txt

    Log File Rotation

    Log files are rotated once each exceeds a threshold max_size in megabytes. Once rotated, the log files are compressed (gzip) to reduce the disk usage. Aged logs are cleaned up once their age exceeds max_age days.

    Configure log rotation using the logging.level.$rotation property.

    For pre-2.1 log rotation — see: Log Rotation pre-2.1

    Log Redaction

    All log outputs can be redacted, removing any user-data considered private. Enable this feature by setting the logging.redaction_level property.