Logs and logging

Logs and logging

Couchbase Server creates a number of different log files depending on the component of the system that produce the error, and the level and severity of the problem being reported.

Platform Location
Linux /opt/couchbase/var/lib/couchbase/logs
Windows C:\Program Files\Couchbase\Server\var\lib\couchbase\logs Assumes default installation location
Mac OS X /Users/couchbase/Library/Application Support/Couchbase/var/lib/couchbase/logs

For memchached logs, individual log files are automatically numbered with the number suffix incremented for each new log, and with a maximum of 20 files per log. Individual log file sizes are limited to 10MB by default.

For other logs, when a log file reaches 40MB it will be rotated and compressed. The file will keep 5 rotations (the current rotation plus four compressed rotations). Here is an example list of log files:
-rw-rw---- 1 couchbase couchbase 12M Feb 2 16:15 couchdb.log 
-rw-rw---- 1 couchbase couchbase 4.8M Feb 2 16:13 couchdb.log.1.gz 
-rw-rw---- 1 couchbase couchbase 4.5M Jan 30 17:35 couchdb.log.2.gz 
-rw-rw---- 1 couchbase couchbase 3.9M Jan 30 17:34 couchdb.log.3.gz 
-rw-rw---- 1 couchbase couchbase 5.7M Jan 30 17:30 couchdb.log.4.gz 

In this list, the oldest file has the largest number.

To provide custom rotation settings for each component, use the following :
{disk_sink_opts_disk_debug, 
 [{rotation, [{size, 10485760}, 
              {num_files, 10}]}]}. 

This will rotate the debug.log at 10M and keep 10 copies of the log (the current log and 9 compressed logs).

File Log Contents
couchdb Errors relating to the couchdb subsystem that supports views, indexes and related REST API issues
crash-log.bin Used to pass service crash reports from the babysitter to the ns_server . For example, if the ns_server is available, any crash of the babysitter's child is passed directly to the special crash logger service within the ns_server . If the logger service is not attached to the babysiter, then the babysitter saves that crash report to the disk and the ns_server can later obtain and log it even if the babysitter is restarted.
crash.log.bin.tmp Same as crash-log.bin only a temporary file.
debug Debug level error messages related to the core server management subsystem, excluding information included in the couchdb , xdcr and stats logs.
info Information level error messages related to the core server management subsystem, excluding information included in the couchdb , xdcr and stats logs.
http_access.log The admin access log records server requests (including admin logins) coming through the REST or Couchbase web console. It is output in common log format and contains several important fields such as remote client IP, timestamp, GET/POST request and resource requested, HTTP status code, and so on.
error Error level messages for all subsystems excluding xdcr .
xcdr_error XDCR error messages.
xdcr XDCR information messages.
tmpfail For XDCR, the destination cluster is not able to eject items fast enough to make room for new mutations. XDCR retries several times, without throwing errors, but after a fixed number of attempts the errors are shown to the user. Nevertheless, if a user waits long enough, XDCR eventually retries and is able to replicate the remaining data.
mapreduce_errors JavaScript and other view-processing errors are reported in this file.
views Errors relating to the integration between the view system and the core server subsystem.
stats Contains periodic reports of the core statistics.
memcached.log Contains information relating to the core memcached component, including vBucket and replica and rebalance data streams requests.
reports.log Contains only progress report and crash reports for the Erlang process.

Changing log file location

The default file log location is /opt/couchbase/var/lib/couchbase/logs, however, if you want to change the default log location to a different directory, change the log file configuration option.

Note

To implement a log file location change (from the default), you must be log in as either root or sudo and the Couchbase service must be restarted.

To change the log file configuration:

  1. Log in as root or sudo and navigate to the directory where you installed Couchbase. For example: /opt/couchbase/etc/couchbase/static_config
  2. Edit the static_config file and change the error_logger_mf_dir variable to a different directory. For example: {error_logger_mf_dir, "/home/user/cb/opt/couchbase/var/lib/couchbase/logs"}
  3. Restart the Couchbase service. After restarting the Couchbase service, all subsequent logs will be in the new directory.

Changing logging levels

The default logging level for all log files are set to debug except for couchdb, which is set to info. If you want to change the default logging level, modify the logging level configuration options.

The configuration change can be performed in one of the following ways:

  • persistent
  • dynamic (on the fly, without restarting).

Changing logging levels to be persistent

Logging levels can be changed so that the changes are persistent, that is, the changes continue to be implemented should a Couchbase Server reboot occur.

Note: To implement logging level changes, the Couchbase service must be restarted.

To change logging levels to be persistent:

  1. Log in as root or sudo and navigate to the directory where you installed Couchbase. For example: /opt/couchbase/etc/couchbase/static_config
  2. Edit the static_config file and change the desired log component. For example, parameters with the loglevel_ prefix set the logging level.
  3. Restart the Couchbase service.

After restarting the Couchbase service, logging levels for that component will be changed.

Changing logging levels dynamically

If logging levels are changed dynamically and if a Couchbase server reboot occurs, then the changed logging levels revert to the default.

To change logging levels dynamically, execute a curl POST command using the following syntax:


curl -X POST -u adminName:adminPassword
  HOST:PORT/diag/eval 
  -d ‘ale:set_loglevel(<log_component>,<logging_level>).’

Where:

Log_component
The default log level (except couchdb ) is debug ; for example ns_server . The available loggers are ns_server , couchdb , user , Menelaus , ns_doctor , stats , rebalance , cluster , views, mapreduce_errors , xdcr and error_logger.
Logging_level
The available log levels are debug , info , warning , and error .

curl -X POST -u Administrator:password 
	http://127.0.0.1:8091/diag/eval 
	-d 'ale:set_loglevel(ns_server,error).