github.com/mheon/docker@v0.11.2-0.20150922122814-44f47903a831/docs/reference/logging/journald.md (about)

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