Home Explore Blog CI



docker

4th chunk of `content/manuals/engine/logging/configure.md`
b30fae7e37cb388a46f825667da489f610d4ac4fb6947c520000000100000cc4
### Use environment variables or labels with logging drivers

Some logging drivers add the value of a container's `--env|-e` or `--label`
flags to the container's logs. This example starts a container using the Docker
daemon's default logging driver (in the following example, `json-file`) but
sets the environment variable `os=ubuntu`.

```console
$ docker run -dit --label production_status=testing -e os=ubuntu alpine sh
```

If the logging driver supports it, this adds additional fields to the logging
output. The following output is generated by the `json-file` logging driver:

```json
"attrs":{"production_status":"testing","os":"ubuntu"}
```

## Supported logging drivers

The following logging drivers are supported. See the link to each driver's
documentation for its configurable options, if applicable. If you are using
[logging driver plugins](plugins.md), you may
see more options.

| Driver                                | Description                                                                                                 |
| :------------------------------------ | :---------------------------------------------------------------------------------------------------------- |
| `none`                                | No logs are available for the container and `docker logs` does not return any output.                       |
| [`local`](drivers/local.md)           | Logs are stored in a custom format designed for minimal overhead.                                           |
| [`json-file`](drivers/json-file.md)   | The logs are formatted as JSON. The default logging driver for Docker.                                      |
| [`syslog`](drivers/syslog.md)         | Writes logging messages to the `syslog` facility. The `syslog` daemon must be running on the host machine.  |
| [`journald`](drivers/journald.md)     | Writes log messages to `journald`. The `journald` daemon must be running on the host machine.               |
| [`gelf`](drivers/gelf.md)             | Writes log messages to a Graylog Extended Log Format (GELF) endpoint such as Graylog or Logstash.           |
| [`fluentd`](drivers/fluentd.md)       | Writes log messages to `fluentd` (forward input). The `fluentd` daemon must be running on the host machine. |
| [`awslogs`](drivers/awslogs.md)       | Writes log messages to Amazon CloudWatch Logs.                                                              |
| [`splunk`](drivers/splunk.md)         | Writes log messages to `splunk` using the HTTP Event Collector.                                             |
| [`etwlogs`](drivers/etwlogs.md)       | Writes log messages as Event Tracing for Windows (ETW) events. Only available on Windows platforms.         |
| [`gcplogs`](drivers/gcplogs.md)       | Writes log messages to Google Cloud Platform (GCP) Logging.                                                 |

## Limitations of logging drivers

- Reading log information requires decompressing rotated log files, which causes
  a temporary increase in disk usage (until the log entries from the rotated
  files are read) and an increased CPU usage while decompressing.
- The capacity of the host storage where the Docker data directory resides
  determines the maximum size of the log file information.

Title: Logging Drivers: Environment Variables, Supported Drivers, and Limitations
Summary
Some Docker logging drivers can include container environment variables and labels in the logs. Supported drivers include `none`, `local`, `json-file`, `syslog`, `journald`, `gelf`, `fluentd`, `awslogs`, `splunk`, `etwlogs` (Windows only), and `gcplogs`. Each driver has its own configurable options. Limitations include increased disk and CPU usage during log rotation decompression, and log file size is limited by host storage capacity.