Home Explore Blog CI



docker

2nd chunk of `content/manuals/engine/logging/drivers/journald.md`
41d5311cfc559ccb1fe9d528fe2107b9541c51a967a8d8f400000001000008ac
`C:\ProgramData\docker\config\daemon.json` on Windows Server. For more about
configuring Docker using `daemon.json`, see
[daemon.json](/reference/cli/dockerd.md#daemon-configuration-file).

The following example sets the log driver to `journald`:

```json
{
  "log-driver": "journald"
}
```

Restart Docker for the changes to take effect.

To configure the logging driver for a specific container, use the `--log-driver`
flag on the `docker run` command.

```console
$ docker run --log-driver=journald ...
```

## Options

Use the `--log-opt NAME=VALUE` flag to specify additional `journald` logging
driver options.

| Option         | Required | Description                                                                                                                                                                   |
| :------------- | :------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `tag`          | optional | Specify template to set `CONTAINER_TAG` and `SYSLOG_IDENTIFIER` value in journald logs. Refer to [log tag option documentation](log_tags.md) to customize the log tag format. |
| `labels`       | optional | Comma-separated list of keys of labels, which should be included in message, if these labels are specified for the container.                                                 |
| `labels-regex` | optional | Similar to and compatible with labels. A regular expression to match logging-related labels. Used for advanced [log tag options](log_tags.md).                                |
| `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).                    |

If a collision occurs between `label` and `env` options, the value of the `env`
takes precedence. Each option adds additional fields to the attributes of a

Title: Journald Logging Driver Configuration and Options
Summary
To set the journald driver as the default, configure `daemon.json` and restart Docker. For specific containers, use the `--log-driver` flag in `docker run`. Additional options can be passed with `--log-opt`, including `tag` to customize the log tag format, `labels` and `labels-regex` to include container labels, and `env` and `env-regex` to include environment variables in the logs. `env` values take precedence over `label` values in case of collision.