github.com/jogo/docker@v1.7.0-rc1/docs/sources/reference/logging/journald.md (about) 1 # Journald logging driver 2 3 The `journald` logging driver sends container logs to the [systemd 4 journal](http://www.freedesktop.org/software/systemd/man/systemd-journald.service.html). Log entries can be retrieved using the `journalctl` 5 command or through use of the journal API. 6 7 In addition to the text of the log message itself, the `journald` log 8 driver stores the following metadata in the journal with each message: 9 10 | Field | Description | 11 ----------------------|-------------| 12 | `CONTAINER_ID` | The container ID truncated to 12 characters. | 13 | `CONTAINER_ID_FULL` | The full 64-character container ID. | 14 | `CONTAINER_NAME` | The container name at the time it was started. If you use `docker rename` to rename a container, the new name is not reflected in the journal entries. | 15 16 ## Usage 17 18 You can configure the default logging driver by passing the 19 `--log-driver` option to the Docker daemon: 20 21 docker --log-driver=journald 22 23 You can set the logging driver for a specific container by using the 24 `--log-driver` option to `docker run`: 25 26 docker run --log-driver=journald ... 27 28 ## Note regarding container names 29 30 The value logged in the `CONTAINER_NAME` field is the container name 31 that was set at startup. If you use `docker rename` to rename a 32 container, the new name will not be reflected in the journal entries. 33 Journal entries will continue to use the original name. 34 35 ## Retrieving log messages with journalctl 36 37 You can use the `journalctl` command to retrieve log messages. You 38 can apply filter expressions to limit the retrieved messages to a 39 specific container. For example, to retrieve all log messages from a 40 container referenced by name: 41 42 # journalctl CONTAINER_NAME=webserver 43 44 You can make use of additional filters to further limit the messages 45 retrieved. For example, to see just those messages generated since 46 the system last booted: 47 48 # journalctl -b CONTAINER_NAME=webserver 49 50 Or to retrieve log messages in JSON format with complete metadata: 51 52 # journalctl -o json CONTAINER_NAME=webserver 53 54 ## Retrieving log messages with the journal API 55 56 This example uses the `systemd` Python module to retrieve container 57 logs: 58 59 import systemd.journal 60 61 reader = systemd.journal.Reader() 62 reader.add_match('CONTAINER_NAME=web') 63 64 for msg in reader: 65 print '{CONTAINER_ID_FULL}: {MESSAGE}'.format(**msg) 66