Skip to content

Commit ccc87eb

Browse files
authored
Merge pull request #5438 from thaJeztah/dockerd_logformat
docs, man: dockerd: add documentation for "--log-format" option
2 parents 4f78ffa + baceb4b commit ccc87eb

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

docs/reference/dockerd.md

+30
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ Options:
8080
--label list Set key=value labels to the daemon
8181
--live-restore Enable live restore of docker when containers are still running
8282
--log-driver string Default driver for container logs (default "json-file")
83+
--log-format string Set the logging format ("text"|"json") (default "text")
8384
-l, --log-level string Set the logging level ("debug"|"info"|"warn"|"error"|"fatal") (default "info")
8485
--log-opt map Default log driver options for containers (default map[])
8586
--max-concurrent-downloads int Set the max concurrent downloads (default 3)
@@ -891,6 +892,33 @@ Alternatively, you can set custom locations for CDI specifications using the
891892
When CDI is enabled for a daemon, you can view the configured CDI specification
892893
directories using the `docker info` command.
893894

895+
#### <a name="log-format"></a> Daemon logging format
896+
897+
The `--log-format` option or "log-format" option in the [daemon configuration file](#daemon-configuration-file)
898+
lets you set the format for logs produced by the daemon. The logging format should
899+
only be configured either through the `--log-format` command line option or
900+
through the "log-format" field in the configuration file; using both
901+
the command-line option and the "log-format" field in the configuration
902+
file produces an error. If this option is not set, the default is "text".
903+
904+
The following example configures the daemon through the `--log-format` command
905+
line option to use `json` formatted logs;
906+
907+
```console
908+
$ dockerd --log-format=json
909+
# ...
910+
{"level":"info","msg":"API listen on /var/run/docker.sock","time":"2024-09-16T11:06:08.558145428Z"}
911+
```
912+
913+
The following example shows a `daemon.json` configuration file with the
914+
"log-format" set;
915+
916+
```json
917+
{
918+
"log-format": "json"
919+
}
920+
```
921+
894922
### Miscellaneous options
895923

896924
IP masquerading uses address translation to allow containers without a public
@@ -1123,6 +1151,7 @@ The following is a full example of the allowed configuration options on Linux:
11231151
"labels": [],
11241152
"live-restore": true,
11251153
"log-driver": "json-file",
1154+
"log-format": "text",
11261155
"log-level": "",
11271156
"log-opts": {
11281157
"cache-disabled": "false",
@@ -1217,6 +1246,7 @@ The following is a full example of the allowed configuration options on Windows:
12171246
"insecure-registries": [],
12181247
"labels": [],
12191248
"log-driver": "",
1249+
"log-format": "text",
12201250
"log-level": "",
12211251
"max-concurrent-downloads": 3,
12221252
"max-concurrent-uploads": 5,

man/dockerd.8.md

+4
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ dockerd - Enable daemon mode
5353
[**--label**[=*[]*]]
5454
[**--live-restore**[=**false**]]
5555
[**--log-driver**[=*json-file*]]
56+
[**--log-format**="*text*|*json*"]
5657
[**--log-opt**[=*map[]*]]
5758
[**--mtu**[=*0*]]
5859
[**--max-concurrent-downloads**[=*3*]]
@@ -333,6 +334,9 @@ unix://[/path/to/socket] to use.
333334
Default driver for container logs. Default is **json-file**.
334335
**Warning**: **docker logs** command works only for **json-file** logging driver.
335336

337+
**--log-format**="*text*|*json*"
338+
Set the format for logs produced by the daemon. Default is "text".
339+
336340
**--log-opt**=[]
337341
Logging driver specific options.
338342

0 commit comments

Comments
 (0)