github.com/slava-ustovytski/docker@v1.8.2-rc1/docs/reference/logging/index.md (about)

     1  <!--[metadata]>
     2  +++
     3  title = "Configure logging drivers"
     4  description = "Configure logging driver."
     5  keywords = ["Fluentd, docker, logging, driver"]
     6  [menu.main]
     7  parent = "smn_logging"
     8  +++
     9  <![end-metadata]-->
    10  
    11  
    12  # Configure logging drivers
    13  
    14  The container can have a different logging driver than the Docker daemon. Use
    15  the `--log-driver=VALUE` with the `docker run` command to configure the
    16  container's logging driver. The following options are supported:
    17  
    18  | `none`      | Disables any logging for the container. `docker logs` won't be available with this driver.                                    |
    19  |-------------|-------------------------------------------------------------------------------------------------------------------------------|
    20  | `json-file` | Default logging driver for Docker. Writes JSON messages to file.                                                              |
    21  | `syslog`    | Syslog logging driver for Docker. Writes log messages to syslog.                                                              |
    22  | `journald`  | Journald logging driver for Docker. Writes log messages to `journald`.                                                        |
    23  | `gelf`      | Graylog Extended Log Format (GELF) logging driver for Docker. Writes log messages to a GELF endpoint likeGraylog or Logstash. |
    24  | `fluentd`   | Fluentd logging driver for Docker. Writes log messages to `fluentd` (forward input).                                          |
    25  
    26  The `docker logs`command is available only for the `json-file` logging driver.  
    27  
    28  ### The json-file options
    29  
    30  The following logging options are supported for the `json-file` logging driver:
    31  
    32      --log-opt max-size=[0-9+][k|m|g]
    33      --log-opt max-file=[0-9+]
    34  
    35  Logs that reach `max-size` are rolled over. You can set the size in kilobytes(k), megabytes(m), or gigabytes(g). eg `--log-opt max-size=50m`. If `max-size` is not set, then logs are not rolled over.
    36  
    37  
    38  `max-file` specifies the maximum number of files that a log is rolled over before being discarded. eg `--log-opt max-file=100`. If `max-size` is not set, then `max-file` is not honored.
    39  
    40  If `max-size` and `max-file` are set, `docker logs` only returns the log lines from the newest log file. 
    41  
    42  ### The syslog options
    43  
    44  The following logging options are supported for the `syslog` logging driver:
    45  
    46      --log-opt syslog-address=[tcp|udp]://host:port
    47      --log-opt syslog-address=unix://path
    48      --log-opt syslog-facility=daemon
    49      --log-opt syslog-tag="mailer"
    50  
    51  `syslog-address` specifies the remote syslog server address where the driver connects to.
    52  If not specified it defaults to the local unix socket of the running system.
    53  If transport is either `tcp` or `udp` and `port` is not specified it defaults to `514`
    54  The following example shows how to have the `syslog` driver connect to a `syslog`
    55  remote server at `192.168.0.42` on port `123`
    56  
    57      $ docker run --log-driver=syslog --log-opt syslog-address=tcp://192.168.0.42:123
    58  
    59  The `syslog-facility` option configures the syslog facility. By default, the system uses the
    60  `daemon` value. To override this behavior, you can provide an integer of 0 to 23 or any of
    61  the following named facilities:
    62  
    63  * `kern`
    64  * `user`
    65  * `mail`
    66  * `daemon`
    67  * `auth`
    68  * `syslog`
    69  * `lpr`
    70  * `news`
    71  * `uucp`
    72  * `cron`
    73  * `authpriv`
    74  * `ftp`
    75  * `local0`
    76  * `local1`
    77  * `local2`
    78  * `local3`
    79  * `local4`
    80  * `local5`
    81  * `local6`
    82  * `local7`
    83  
    84  The `syslog-tag` specifies a tag that identifies the container's syslog messages. By default,
    85  the system uses the first 12 characters of the container id. To override this behavior, specify
    86  a `syslog-tag` option
    87  
    88  ## Specify journald options
    89  
    90  The `journald` logging driver stores the container id in the journal's `CONTAINER_ID` field. For detailed information on
    91  working with this logging driver, see [the journald logging driver](/reference/logging/journald/)
    92  reference documentation.
    93  
    94  ## Specify gelf options
    95  
    96  The GELF logging driver supports the following options:
    97  
    98      --log-opt gelf-address=udp://host:port
    99      --log-opt gelf-tag="database"
   100  
   101  The `gelf-address` option specifies the remote GELF server address that the
   102  driver connects to. Currently, only `udp` is supported as the transport and you must
   103  specify a `port` value. The following example shows how to connect the `gelf`
   104  driver to a GELF remote server at `192.168.0.42` on port `12201`
   105  
   106      $ docker run --log-driver=gelf --log-opt gelf-address=udp://192.168.0.42:12201
   107  
   108  The `gelf-tag` option specifies a tag for easy container identification.
   109  
   110  ## Specify fluentd options
   111  
   112  You can use the `--log-opt NAME=VALUE` flag to specify these additional Fluentd logging driver options.
   113  
   114   - `fluentd-address`: specify `host:port` to connect [localhost:24224]
   115   - `fluentd-tag`: specify tag for `fluentd` message, 
   116  
   117  When specifying a `fluentd-tag` value, you can use the following markup tags:
   118  
   119   - `{{.ID}}`: short container id (12 characters)
   120   - `{{.FullID}}`: full container id
   121   - `{{.Name}}`: container name
   122  
   123  For example, to specify both additional options:
   124  
   125  `docker run --log-driver=fluentd --log-opt fluentd-address=localhost:24224 --log-opt fluentd-tag=docker.{{.Name}}`
   126  
   127  If container cannot connect to the Fluentd daemon on the specified address,
   128  the container stops immediately. For detailed information on working with this
   129  logging driver, see [the fluentd logging driver](/reference/logging/fluentd/)