chore: tier 1 freshness: content/config/containers/logging/configure.md

Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
This commit is contained in:
David Karlsson 2023-10-27 13:40:24 +02:00
parent 11d7363943
commit 36e36d030f
1 changed files with 40 additions and 43 deletions

View File

@ -1,5 +1,5 @@
---
description: Configure logging driver.
description: Learn how to configure logging driver for the Docker daemon
keywords: docker, logging, driver
title: Configure logging drivers
aliases:
@ -13,13 +13,13 @@ Docker includes multiple logging mechanisms to help you
[get information from running containers and services](index.md).
These mechanisms are called logging drivers. Each Docker daemon has a default
logging driver, which each container uses unless you configure it to use a
different logging driver, or "log-driver" for short.
different logging driver, or log driver for short.
As a default, Docker uses the [`json-file` logging driver](json-file.md), which
caches container logs as JSON internally. In addition to using the logging drivers
included with Docker, you can also implement and use [logging driver plugins](plugins.md).
> **Tip: use the "local" logging driver to prevent disk-exhaustion**
> **Tip: use the `local` logging driver to prevent disk-exhaustion**
>
> By default, no log-rotation is performed. As a result, log-files stored by the
> default [`json-file` logging driver](json-file.md) logging driver can cause
@ -30,12 +30,13 @@ included with Docker, you can also implement and use [logging driver plugins](pl
> to remain backward compatibility with older versions of Docker, and for situations
> where Docker is used as runtime for Kubernetes.
>
> For other situations, the "local" logging driver is recommended as it performs
> For other situations, the `local` logging driver is recommended as it performs
> log-rotation by default, and uses a more efficient file format. Refer to the
> [Configure the default logging driver](#configure-the-default-logging-driver)
> section below to learn how to configure the "local" logging driver as a default,
> section below to learn how to configure the `local` logging driver as a default,
> and the [local file logging driver](local.md) page for more details about the
> "local" logging driver.
> `local` logging driver.
{ .tip }
## Configure the default logging driver
@ -71,7 +72,7 @@ example sets four configurable options on the `json-file` logging driver:
```
Restart Docker for the changes to take effect for newly created containers.
Existing containers do not use the new logging configuration.
Existing containers don't use the new logging configuration automatically.
> **Note**
>
@ -79,19 +80,17 @@ Existing containers do not use the new logging configuration.
> be provided as strings. Boolean and numeric values (such as the value for
> `max-file` in the example above) must therefore be enclosed in quotes (`"`).
If you do not specify a logging driver, the default is `json-file`.
If you don't specify a logging driver, the default is `json-file`.
To find the current default logging driver for the Docker daemon, run
`docker info` and search for `Logging Driver`. You can use the following
command on Linux, macOS, or PowerShell on Windows:
```console
$ docker info --format '{{.LoggingDriver}}'
json-file
```
> **Note**
>
> Changing the default logging driver or logging driver options in the daemon
@ -121,21 +120,19 @@ To find the current logging driver for a running container, if the daemon
is using the `json-file` logging driver, run the following `docker inspect`
command, substituting the container name or ID for `<CONTAINER>`:
```console
$ docker inspect -f '{{.HostConfig.LogConfig.Type}}' <CONTAINER>
json-file
```
## Configure the delivery mode of log messages from container to log driver
Docker provides two modes for delivering messages from the container to the log
driver:
* (default) direct, blocking delivery from container to driver
* non-blocking delivery that stores log messages in an intermediate per-container buffer for consumption by driver
- (default) direct, blocking delivery from container to driver
- non-blocking delivery that stores log messages in an intermediate per-container buffer for consumption by driver
The `non-blocking` message delivery mode prevents applications from blocking due
to logging back pressure. Applications are likely to fail in unexpected ways when
@ -165,8 +162,8 @@ $ docker run -it --log-opt mode=non-blocking --log-opt max-buffer-size=4m alpine
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 (let's assume `json-file`) but sets the
environment variable `os=ubuntu`.
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
@ -187,7 +184,7 @@ documentation for its configurable options, if applicable. If you are using
see more options.
| Driver | Description |
|:------------------------------|:--------------------------------------------------------------------------------------------------------------|
| :---------------------------- | :---------------------------------------------------------------------------------------------------------- |
| `none` | No logs are available for the container and `docker logs` does not return any output. |
| [`local`](local.md) | Logs are stored in a custom format designed for minimal overhead. |
| [`json-file`](json-file.md) | The logs are formatted as JSON. The default logging driver for Docker. |