Configure loggingedit

The logging section of the apm-server.yml config file contains options for configuring the logging output. The logging system can write logs to the syslog or rotate log files. If logging is not explicitly configured the file output is used.

logging.level: info
logging.to_files: true
logging.files:
  path: /var/log/apm-server
  name: apm-server
  keepfiles: 7
  permissions: 0644

In addition to setting logging options in the config file, you can modify the logging output configuration from the command line. See Command reference.

Configuration optionsedit

You can specify the following options in the logging section of the apm-server.yml config file:

logging.to_syslogedit

When true, writes all logging output to the syslog.

logging.to_eventlogedit

When true, writes all logging output to the Windows Event Log.

logging.to_filesedit

When true, writes all logging output to files. The log files are automatically rotated when the log file size limit is reached.

APM Server only creates a log file if there is logging output. For example, if you set the log level to error and there are no errors, there will be no log file in the directory specified for logs.

logging.leveledit

Minimum log level. One of debug, info, warning, or error. The default log level is info.

debug
Logs debug messages, including a detailed printout of all events flushed. Also logs informational messages, warnings, errors, and critical errors. When the log level is debug, you can specify a list of selectors to display debug messages for specific components. If no selectors are specified, the * selector is used to display debug messages for all components.
info
Logs informational messages, including the number of events that are published. Also logs any warnings, errors, or critical errors.
warning
Logs warnings, errors, and critical errors.
error
Logs errors and critical errors.

logging.selectorsedit

The list of debugging-only selector tags used by different APM Server components. Use * to enable debug output for all components. For example add publish to display all the debug messages related to event publishing. When starting apm-server, selectors can be overwritten using the -d command line option (-d also sets the debug log level).

logging.metrics.enablededit

If enabled, APM Server periodically logs its internal metrics that have changed in the last period. For each metric that changed, the delta from the value at the beginning of the period is logged. Also, the total values for all non-zero internal metrics are logged on shutdown. The default is true.

Here is an example log line:

2017-12-17T19:17:42.667-0500    INFO    [metrics]       log/log.go:110  Non-zero metrics in the last 30s: beat.info.uptime.ms=30004 beat.memstats.gc_next=5046416

Note that we currently offer no backwards compatible guarantees for the internal metrics and for this reason they are also not documented.

logging.metrics.periodedit

The period after which to log the internal metrics. The default is 30s.

logging.files.pathedit

The directory that log files are written to. The default is the logs path. See the Directory layout section for details.

logging.files.nameedit

The name of the file that logs are written to. The default is apm-server.

logging.files.rotateeverybytesedit

The maximum size of a log file. If the limit is reached, a new log file is generated. The default size limit is 10485760 (10 MB).

logging.files.keepfilesedit

The number of most recent rotated log files to keep on disk. Older files are deleted during log rotation. The default value is 7. The keepfiles options has to be in the range of 2 to 1024 files.

logging.files.permissionsedit

The permissions mask to apply when rotating log files. The default value is 0600. The permissions option must be a valid Unix-style file permissions mask expressed in octal notation. In Go, numbers in octal notation must start with 0.

Examples:

  • 0644: give read and write access to the file owner, and read access to all others.
  • 0600: give read and write access to the file owner, and no access to all others.
  • 0664: give read and write access to the file owner and members of the group associated with the file, as well as read access to all other users.

logging.jsonedit

When true, logs messages in JSON format. The default is false.

Logging formatedit

The logging format is generally the same for each logging output. The one exception is with the syslog output where the timestamp is not included in the message because syslog adds its own timestamp.

Each log message consists of the following parts:

  • Timestamp in ISO8601 format
  • Level
  • Logger name contained in brackets (Optional)
  • File name and line number of the caller
  • Message
  • Structured data encoded in JSON (Optional)

Below are some samples:

2017-12-17T18:54:16.241-0500 INFO logp/core_test.go:13 unnamed global logger

2017-12-17T18:54:16.242-0500 INFO [example] logp/core_test.go:16 some message

2017-12-17T18:54:16.242-0500 INFO [example] logp/core_test.go:19 some message {"x": 1}