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