github.com/ncdc/docker@v0.10.1-0.20160129113957-6c6729ef5b74/docs/admin/logging/overview.md (about)

     1  <!--[metadata]>
     2  +++
     3  aliases = ["/engine/reference/logging/overview/"]
     4  title = "Configuring Logging Drivers"
     5  description = "Configure logging driver."
     6  keywords = ["docker, logging, driver, Fluentd"]
     7  [menu.main]
     8  parent = "smn_logging"
     9  weight=-1
    10  +++
    11  <![end-metadata]-->
    12  
    13  
    14  # Configure logging drivers
    15  
    16  The container can have a different logging driver than the Docker daemon. Use
    17  the `--log-driver=VALUE` with the `docker run` command to configure the
    18  container's logging driver. The following options are supported:
    19  
    20  | `none`      | Disables any logging for the container. `docker logs` won't be available with this driver.                                    |
    21  |-------------|-------------------------------------------------------------------------------------------------------------------------------|
    22  | `json-file` | Default logging driver for Docker. Writes JSON messages to file.                                                              |
    23  | `syslog`    | Syslog logging driver for Docker. Writes log messages to syslog.                                                              |
    24  | `journald`  | Journald logging driver for Docker. Writes log messages to `journald`.                                                        |
    25  | `gelf`      | Graylog Extended Log Format (GELF) logging driver for Docker. Writes log messages to a GELF endpoint likeGraylog or Logstash. |
    26  | `fluentd`   | Fluentd logging driver for Docker. Writes log messages to `fluentd` (forward input).                                          |
    27  | `awslogs`   | Amazon CloudWatch Logs logging driver for Docker. Writes log messages to Amazon CloudWatch Logs.                              |
    28  | `splunk`    | Splunk logging driver for Docker. Writes log messages to `splunk` using HTTP Event Collector.                                 |
    29  
    30  The `docker logs`command is available only for the `json-file` and `journald`
    31  logging drivers.
    32  
    33  The `labels` and `env` options add additional attributes for use with logging drivers that accept them. Each option takes a comma-separated list of keys. If there is collision between `label` and `env` keys, the value of the `env` takes precedence.
    34  
    35  To use attributes, specify them when you start the Docker daemon.
    36  
    37  ```
    38  docker daemon --log-driver=json-file --log-opt labels=foo --log-opt env=foo,fizz
    39  ```
    40  
    41  Then, run a container and specify values for the `labels` or `env`.  For example, you might use this:
    42  
    43  ```
    44  docker run --label foo=bar -e fizz=buzz -d -P training/webapp python app.py
    45  ```
    46  
    47  This adds additional fields to the log depending on the driver, e.g. for
    48  `json-file` that looks like:
    49  
    50      "attrs":{"fizz":"buzz","foo":"bar"}
    51  
    52  
    53  ## json-file options
    54  
    55  The following logging options are supported for the `json-file` logging driver:
    56  
    57      --log-opt max-size=[0-9+][k|m|g]
    58      --log-opt max-file=[0-9+]
    59      --log-opt labels=label1,label2
    60      --log-opt env=env1,env2
    61  
    62  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.
    63  
    64  `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.
    65  
    66  If `max-size` and `max-file` are set, `docker logs` only returns the log lines from the newest log file.
    67  
    68  
    69  ## syslog options
    70  
    71  The following logging options are supported for the `syslog` logging driver:
    72  
    73      --log-opt syslog-address=[tcp|udp|tcp+tls]://host:port
    74      --log-opt syslog-address=unix://path
    75      --log-opt syslog-facility=daemon
    76      --log-opt syslog-tls-ca-cert=/etc/ca-certificates/custom/ca.pem
    77      --log-opt syslog-tls-cert=/etc/ca-certificates/custom/cert.pem
    78      --log-opt syslog-tls-key=/etc/ca-certificates/custom/key.pem
    79      --log-opt syslog-tls-skip-verify=true
    80      --log-opt tag="mailer"
    81  
    82  `syslog-address` specifies the remote syslog server address where the driver connects to.
    83  If not specified it defaults to the local unix socket of the running system.
    84  If transport is either `tcp` or `udp` and `port` is not specified it defaults to `514`
    85  The following example shows how to have the `syslog` driver connect to a `syslog`
    86  remote server at `192.168.0.42` on port `123`
    87  
    88      $ docker run --log-driver=syslog --log-opt syslog-address=tcp://192.168.0.42:123
    89  
    90  The `syslog-facility` option configures the syslog facility. By default, the system uses the
    91  `daemon` value. To override this behavior, you can provide an integer of 0 to 23 or any of
    92  the following named facilities:
    93  
    94  * `kern`
    95  * `user`
    96  * `mail`
    97  * `daemon`
    98  * `auth`
    99  * `syslog`
   100  * `lpr`
   101  * `news`
   102  * `uucp`
   103  * `cron`
   104  * `authpriv`
   105  * `ftp`
   106  * `local0`
   107  * `local1`
   108  * `local2`
   109  * `local3`
   110  * `local4`
   111  * `local5`
   112  * `local6`
   113  * `local7`
   114  
   115  `syslog-tls-ca-cert` specifies the absolute path to the trust certificates
   116  signed by the CA. This option is ignored if the address protocol is not `tcp+tls`.
   117  
   118  `syslog-tls-cert` specifies the absolute path to the TLS certificate file.
   119  This option is ignored if the address protocol is not `tcp+tls`.
   120  
   121  `syslog-tls-key` specifies the absolute path to the TLS key file.
   122  This option is ignored if the address protocol is not `tcp+tls`.
   123  
   124  `syslog-tls-skip-verify` configures the TLS verification.
   125  This verification is enabled by default, but it can be overriden by setting
   126  this option to `true`. This option is ignored if the address protocol is not `tcp+tls`.
   127  
   128  By default, Docker uses the first 12 characters of the container ID to tag log messages.
   129  Refer to the [log tag option documentation](log_tags.md) for customizing
   130  the log tag format.
   131  
   132  
   133  ## journald options
   134  
   135  The `journald` logging driver stores the container id in the journal's `CONTAINER_ID` field. For detailed information on
   136  working with this logging driver, see [the journald logging driver](journald.md)
   137  reference documentation.
   138  
   139  ## gelf options
   140  
   141  The GELF logging driver supports the following options:
   142  
   143      --log-opt gelf-address=udp://host:port
   144      --log-opt tag="database"
   145      --log-opt labels=label1,label2
   146      --log-opt env=env1,env2
   147  
   148  The `gelf-address` option specifies the remote GELF server address that the
   149  driver connects to. Currently, only `udp` is supported as the transport and you must
   150  specify a `port` value. The following example shows how to connect the `gelf`
   151  driver to a GELF remote server at `192.168.0.42` on port `12201`
   152  
   153      $ docker run --log-driver=gelf --log-opt gelf-address=udp://192.168.0.42:12201
   154  
   155  By default, Docker uses the first 12 characters of the container ID to tag log messages.
   156  Refer to the [log tag option documentation](log_tags.md) for customizing
   157  the log tag format.
   158  
   159  The `labels` and `env` options are supported by the gelf logging
   160  driver. It adds additional key on the `extra` fields, prefixed by an
   161  underscore (`_`).
   162  
   163      // […]
   164      "_foo": "bar",
   165      "_fizz": "buzz",
   166      // […]
   167  
   168  
   169  ## fluentd options
   170  
   171  You can use the `--log-opt NAME=VALUE` flag to specify these additional Fluentd logging driver options.
   172  
   173   - `fluentd-address`: specify `host:port` to connect [localhost:24224]
   174   - `tag`: specify tag for `fluentd` message,
   175   - `fail-on-startup-error`: true/false; Should the logging driver fail container startup in case of connect error during startup. Default: true (backwards compatible)
   176   - `buffer-limit`: Size limit (bytes) for the buffer which is used to buffer messages in case of connection outages. Default: 1M
   177  
   178  For example, to specify both additional options:
   179  
   180  `docker run --log-driver=fluentd --log-opt fluentd-address=localhost:24224 --log-opt tag=docker.{{.Name}}`
   181  
   182  If container cannot connect to the Fluentd daemon on the specified address,
   183  the container stops immediately. For detailed information on working with this
   184  logging driver, see [the fluentd logging driver](fluentd.md)
   185  
   186  
   187  ## Specify Amazon CloudWatch Logs options
   188  
   189  The Amazon CloudWatch Logs logging driver supports the following options:
   190  
   191      --log-opt awslogs-region=<aws_region>
   192      --log-opt awslogs-group=<log_group_name>
   193      --log-opt awslogs-stream=<log_stream_name>
   194  
   195  
   196  For detailed information on working with this logging driver, see [the awslogs logging driver](awslogs.md) reference documentation.
   197  
   198  ## Splunk options
   199  
   200  The Splunk logging driver requires the following options:
   201  
   202      --log-opt splunk-token=<splunk_http_event_collector_token>
   203      --log-opt splunk-url=https://your_splunk_instance:8088
   204  
   205  For detailed information about working with this logging driver, see the [Splunk logging driver](splunk.md)
   206  reference documentation.