From b44c3deac200ec3e26b1e6a5d3948d7b80134b96 Mon Sep 17 00:00:00 2001 From: David Karlsson <35727626+dvdksn@users.noreply.github.com> Date: Fri, 27 Oct 2023 14:35:47 +0200 Subject: [PATCH] chore: tier 1 freshness: content/config/containers/logging/json-file.md Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com> --- .../config/containers/logging/json-file.md | 40 ++++++++++--------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/content/config/containers/logging/json-file.md b/content/config/containers/logging/json-file.md index d7ce502c41..5f6999b3dd 100644 --- a/content/config/containers/logging/json-file.md +++ b/content/config/containers/logging/json-file.md @@ -1,10 +1,10 @@ --- -description: Describes how to use the json-file logging driver. +description: Learn how to use the json-file logging driver with Docker Engine keywords: json-file, docker, logging, driver title: JSON File logging driver aliases: -- /engine/reference/logging/json-file/ -- /engine/admin/logging/json-file/ + - /engine/reference/logging/json-file/ + - /engine/admin/logging/json-file/ --- By default, Docker captures the standard output (and standard error) of all your containers, @@ -13,15 +13,20 @@ origin (`stdout` or `stderr`) and its timestamp. Each log file contains informat only one container. ```json -{"log":"Log line is here\n","stream":"stdout","time":"2019-01-01T11:11:11.111111111Z"} +{ + "log": "Log line is here\n", + "stream": "stdout", + "time": "2019-01-01T11:11:11.111111111Z" +} ``` -> *Warning* +> **Warning** > > The `json-file` logging driver uses file-based storage. These files are designed > to be exclusively accessed by the Docker daemon. Interacting with these files > with external tools may interfere with Docker's logging system and result in > unexpected behavior, and should be avoided. +{ .warning } ## Usage @@ -40,7 +45,7 @@ and `max-file` options to enable automatic log-rotation. "log-driver": "json-file", "log-opts": { "max-size": "10m", - "max-file": "3" + "max-file": "3" } } ``` @@ -52,7 +57,7 @@ and `max-file` options to enable automatic log-rotation. > `max-file` in the example above) must therefore be enclosed in quotes (`"`). 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. You can set the logging driver for a specific container by using the `--log-driver` flag to `docker container create` or `docker run`: @@ -67,16 +72,15 @@ $ docker run \ The `json-file` logging driver supports the following logging options: -| Option | Description | Example value | -|:---------------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:--------------------------------------------------| -| `max-size` | The maximum size of the log before it is rolled. A positive integer plus a modifier representing the unit of measure (`k`, `m`, or `g`). Defaults to -1 (unlimited). | `--log-opt max-size=10m` | -| `max-file` | The maximum number of log files that can be present. If rolling the logs creates excess files, the oldest file is removed. **Only effective when `max-size` is also set.** A positive integer. Defaults to 1. | `--log-opt max-file=3` | -| `labels` | Applies when starting the Docker daemon. A comma-separated list of logging-related labels this daemon accepts. Used for advanced [log tag options](log_tags.md). | `--log-opt labels=production_status,geo` | -| `labels-regex` | Similar to and compatible with `labels`. A regular expression to match logging-related labels. Used for advanced [log tag options](log_tags.md). | `--log-opt labels-regex=^(production_status|geo)` | -| `env` | Applies when starting the Docker daemon. A comma-separated list of logging-related environment variables this daemon accepts. Used for advanced [log tag options](log_tags.md). | `--log-opt env=os,customer` | -| `env-regex` | Similar to and compatible with `env`. A regular expression to match logging-related environment variables. Used for advanced [log tag options](log_tags.md). | `--log-opt env-regex=^(os|customer)` | -| `compress` | Toggles compression for rotated logs. Default is `disabled`. | `--log-opt compress=true` | - +| Option | Description | Example value | +| :------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :------------------------------------------ | ---------- | +| `max-size` | The maximum size of the log before it is rolled. A positive integer plus a modifier representing the unit of measure (`k`, `m`, or `g`). Defaults to -1 (unlimited). | `--log-opt max-size=10m` | +| `max-file` | The maximum number of log files that can be present. If rolling the logs creates excess files, the oldest file is removed. **Only effective when `max-size` is also set.** A positive integer. Defaults to 1. | `--log-opt max-file=3` | +| `labels` | Applies when starting the Docker daemon. A comma-separated list of logging-related labels this daemon accepts. Used for advanced [log tag options](log_tags.md). | `--log-opt labels=production_status,geo` | +| `labels-regex` | Similar to and compatible with `labels`. A regular expression to match logging-related labels. Used for advanced [log tag options](log_tags.md). | `--log-opt labels-regex=^(production_status | geo)` | +| `env` | Applies when starting the Docker daemon. A comma-separated list of logging-related environment variables this daemon accepts. Used for advanced [log tag options](log_tags.md). | `--log-opt env=os,customer` | +| `env-regex` | Similar to and compatible with `env`. A regular expression to match logging-related environment variables. Used for advanced [log tag options](log_tags.md). | `--log-opt env-regex=^(os | customer)` | +| `compress` | Toggles compression for rotated logs. Default is `disabled`. | `--log-opt compress=true` | ### Examples @@ -85,4 +89,4 @@ files no larger than 10 megabytes each. ```console $ docker run -it --log-opt max-size=10m --log-opt max-file=3 alpine ash -``` \ No newline at end of file +```