github.com/chenchun/docker@v1.3.2-0.20150629222414-20467faf132b/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. No logging options are supported for this driver. | 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 syslog options 29 30 The following logging options are supported for the `syslog` logging driver: 31 32 --log-opt syslog-address=[tcp|udp]://host:port 33 --log-opt syslog-address=unix://path 34 --log-opt syslog-facility=daemon 35 --log-opt syslog-tag="mailer" 36 37 `syslog-address` specifies the remote syslog server address where the driver connects to. 38 If not specified it defaults to the local unix socket of the running system. 39 If transport is either `tcp` or `udp` and `port` is not specified it defaults to `514` 40 The following example shows how to have the `syslog` driver connect to a `syslog` 41 remote server at `192.168.0.42` on port `123` 42 43 $ docker run --log-driver=syslog --log-opt syslog-address=tcp://192.168.0.42:123 44 45 The `syslog-facility` option configures the syslog facility. By default, the system uses the 46 `daemon` value. To override this behavior, you can provide an integer of 0 to 23 or any of 47 the following named facilities: 48 49 * `kern` 50 * `user` 51 * `mail` 52 * `daemon` 53 * `auth` 54 * `syslog` 55 * `lpr` 56 * `news` 57 * `uucp` 58 * `cron` 59 * `authpriv` 60 * `ftp` 61 * `local0` 62 * `local1` 63 * `local2` 64 * `local3` 65 * `local4` 66 * `local5` 67 * `local6` 68 * `local7` 69 70 The `syslog-tag` specifies a tag that identifies the container's syslog messages. By default, 71 the system uses the first 12 characters of the container id. To override this behavior, specify 72 a `syslog-tag` option 73 74 ## Specify journald options 75 76 The `journald` logging driver sotres the container id in the journal's `CONTAINER_ID` field. For detailed information on 77 working with this logging driver, see [the journald logging driver](/reference/logging/journald/) 78 reference documentation. 79 80 ## Specify gelf options 81 82 The GELF logging driver supports the following options: 83 84 --log-opt gelf-address=udp://host:port 85 --log-opt gelf-tag="database" 86 87 The `gelf-address` option specifies the remote GELF server address that the 88 driver connects to. Currently, only `udp` is supported as the transport and you must 89 specify a `port` value. The following example shows how to connect the `gelf` 90 driver to a GELF remote server at `192.168.0.42` on port `12201` 91 92 $ docker run --log-driver=gelf --log-opt gelf-address=udp://192.168.0.42:12201 93 94 The `gelf-tag` option specifies a tag for easy container identification. 95 96 ## Specify fluentd options 97 98 You can use the `--log-opt NAME=VALUE` flag to specify these additional Fluentd logging driver options. 99 100 - `fluentd-address`: specify `host:port` to connect [localhost:24224] 101 - `fluentd-tag`: specify tag for `fluentd` message, 102 103 When specifying a `fluentd-tag` value, you can use the following markup tags: 104 105 - `{{.ID}}`: short container id (12 characters) 106 - `{{.FullID}}`: full container id 107 - `{{.Name}}`: container name 108 109 For example, to specify both additional options: 110 111 `docker run --log-driver=fluentd --log-opt fluentd-address=localhost:24224 --log-opt fluentd-tag=docker.{{.Name}}` 112 113 If container cannot connect to the Fluentd daemon on the specified address, 114 the container stops immediately. For detailed information on working with this 115 logging driver, see [the journald logging driver](/reference/logging/fluentd/)