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