mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
enable syslog logger to have access to env and labels
Signed-off-by: Alan Scherger <flyinprogrammer@gmail.com>
This commit is contained in:
parent
f62b26571a
commit
f67b711277
3 changed files with 30 additions and 0 deletions
|
@ -188,6 +188,8 @@ func parseAddress(address string) (string, string, error) {
|
|||
func ValidateLogOpt(cfg map[string]string) error {
|
||||
for key := range cfg {
|
||||
switch key {
|
||||
case "env":
|
||||
case "labels":
|
||||
case "syslog-address":
|
||||
case "syslog-facility":
|
||||
case "syslog-tag":
|
||||
|
|
|
@ -46,6 +46,26 @@ For advanced usage, the generated tag's use [go
|
|||
templates](http://golang.org/pkg/text/template/) and the container's [logging
|
||||
context](https://github.com/docker/docker/blob/master/daemon/logger/context.go).
|
||||
|
||||
As an example of what is possible with the syslog logger:
|
||||
|
||||
```
|
||||
$ docker run -it --rm \
|
||||
--log-driver syslog \
|
||||
--log-opt tag="{{ (.ExtraAttributes nil).SOME_ENV_VAR }}" \
|
||||
--log-opt env=SOME_ENV_VAR \
|
||||
-e SOME_ENV_VAR=logtester.1234 \
|
||||
flyinprogrammer/logtester
|
||||
```
|
||||
|
||||
Results in logs like this:
|
||||
|
||||
```
|
||||
Apr 1 15:22:17 ip-10-27-39-73 docker/logtester.1234[45499]: + exec app
|
||||
Apr 1 15:22:17 ip-10-27-39-73 docker/logtester.1234[45499]: 2016-04-01 15:22:17.075416751 +0000 UTC stderr msg: 1
|
||||
```
|
||||
|
||||
|
||||
|
||||
>**Note**:The driver specific log options `syslog-tag`, `fluentd-tag` and
|
||||
>`gelf-tag` still work for backwards compatibility. However, going forward you
|
||||
>should standardize on using the generic `tag` log option instead.
|
||||
|
|
|
@ -81,6 +81,8 @@ The following logging options are supported for the `syslog` logging driver:
|
|||
--log-opt syslog-tls-skip-verify=true
|
||||
--log-opt tag="mailer"
|
||||
--log-opt syslog-format=[rfc5424|rfc5424micro|rfc3164]
|
||||
--log-opt env=ENV1,ENV2,ENV3
|
||||
--log-opt labels=label1,label2,label3
|
||||
|
||||
`syslog-address` specifies the remote syslog server address where the driver connects to.
|
||||
If not specified it defaults to the local unix socket of the running system.
|
||||
|
@ -128,6 +130,7 @@ This option is ignored if the address protocol is not `tcp+tls`.
|
|||
This verification is enabled by default, but it can be overriden by setting
|
||||
this option to `true`. This option is ignored if the address protocol is not `tcp+tls`.
|
||||
|
||||
`tag` configures a string that is appended to the APP-NAME in the syslog message.
|
||||
By default, Docker uses the first 12 characters of the container ID to tag log messages.
|
||||
Refer to the [log tag option documentation](log_tags.md) for customizing
|
||||
the log tag format.
|
||||
|
@ -138,6 +141,11 @@ Specify rfc3164 to perform logging in RFC-3164 compatible format. Specify rfc542
|
|||
logging in RFC-5424 compatible format. Specify rfc5424micro to perform logging in RFC-5424
|
||||
compatible format with microsecond timestamp resolution.
|
||||
|
||||
`env` should be a comma-separated list of keys of environment variables. Used for
|
||||
advanced [log tag options](log_tags.md).
|
||||
|
||||
`labels` should be a comma-separated list of keys of labels. Used for advanced
|
||||
[log tag options](log_tags.md).
|
||||
|
||||
## journald options
|
||||
|
||||
|
|
Loading…
Reference in a new issue