diff --git a/engine/admin/logging/gcplogs.md b/engine/admin/logging/gcplogs.md index e99518051e..f0c1c4ebd1 100644 --- a/engine/admin/logging/gcplogs.md +++ b/engine/admin/logging/gcplogs.md @@ -63,8 +63,8 @@ Cloud Logging driver options: |:----------------|:---------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------| | `gcp-project` | optional | Which GCP project to log to. Defaults to discovering this value from the GCE metadata service. | | `gcp-log-cmd` | optional | Whether to log the command that the container was started with. Defaults to false. | -| `labels` | optional | Comma-separated list of keys of labels, which should be included in message, if these labels are specified for container. | -| `env` | optional | Comma-separated list of keys of environment variables, which should be included in message, if these variables are specified for container. | +| `labels` | optional | Comma-separated list of keys of labels, which should be included in message, if these labels are specified for the container. | +| `env` | optional | Comma-separated list of keys of environment variables, which should be included in message, if these variables are specified for the container. | | `env-regex` | optional | Similar to and compatible with `env`. A regular expression to match logging-related environment variables. Used for advanced [log tag options](log_tags.md). | | `gcp-meta-zone` | optional | Zone name for the instance. | | `gcp-meta-name` | optional | Instance name. | diff --git a/engine/admin/logging/journald.md b/engine/admin/logging/journald.md index 2604c82fca..53341d4407 100644 --- a/engine/admin/logging/journald.md +++ b/engine/admin/logging/journald.md @@ -50,24 +50,29 @@ $ docker run --log-driver=journald ... ## Options -Use the `--log-opt NAME=VALUE` flag to specify additional `journald` logging -driver options. +Use the `--log-opt NAME=VALUE` flag to specify additional `journald` logging driver options. -### `tag` +| Option | Required | Description | +| -- | -- | -- | +| `tag` | optional | Specify template to set `CONTAINER_TAG` value in journald logs. Refer to [log tag option documentation](/engine/admin/logging/log_tags/) to customize the log tag format | +| `label` | optional | Comma-separated list of keys of labels, which should be included in message, if these labels are specified for the container. | +| `env` | optional | Comma-separated list of keys of environment variables, which should be included in message, if these variables are specified for the container. | +| `env-regex` | optional | Similar to and compatible with env. A regular expression to match logging-related environment variables. Used for advanced [log tag options](/engine/admin/logging/log_tags/). -Specify template to set `CONTAINER_TAG` value in `journald` logs. Refer to -[log tag option documentation](log_tags.md) to customize the log tag format. +If a collision occurs between label and env keys, the value of the env takes precedence. Each option adds additional fields to the attributes of a logging message. -### `labels`, `env`, and `env-regex` +Below is an example of the logging options required to log to journald. -The `labels` and `env` options each take a comma-separated list of keys. If -there is collision between `label` and `env` keys, the value of the `env` takes -precedence. Each option adds additional metadata to the journal with each -message. +```bash +docker run --log-driver=journald \ + --log-opt labels=location \ + --log-opt env=TEST \ + --env "TEST=false" \ + --label location=west \ + your/application +``` -`env-regex` is similar to and compatible with `env`. Set it to a regular -expression to match logging-related environment variables. It is used for -advanced [log tag options](log_tags.md). +This configuration also directs the driver to include in the payload the label location, and the environment variable TEST. If the `--env "TEST=false"` or `--label location=west` arguments were omitted, the corresponding key would not be set in the journald log. ## Note regarding container names