{"action":"created","issue":{"url":"https://api.github.com/repos/docker/docker/issues/7195","labels_url":"https://api.github.com/repos/docker/docker/issues/7195/labels{/name}","comments_url":"https://api.github.com/repos/docker/docker/issues/7195/comments","events_url":"https://api.github.com/repos/docker/docker/issues/7195/events","html_url":"https://github.com/docker/docker/issues/7195","id":38562156,"number":7195,"title":"Proposal: Logging drivers","user":{"login":"crosbymichael","id":749551,"avatar_url":"https://avatars.githubusercontent.com/u/749551?v=3","gravatar_id":"","url":"https://api.github.com/users/crosbymichael","html_url":"https://github.com/crosbymichael","followers_url":"https://api.github.com/users/crosbymichael/followers","following_url":"https://api.github.com/users/crosbymichael/following{/other_user}","gists_url":"https://api.github.com/users/crosbymichael/gists{/gist_id}","starred_url":"https://api.github.com/users/crosbymichael/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crosbymichael/subscriptions","organizations_url":"https://api.github.com/users/crosbymichael/orgs","repos_url":"https://api.github.com/users/crosbymichael/repos","events_url":"https://api.github.com/users/crosbymichael/events{/privacy}","received_events_url":"https://api.github.com/users/crosbymichael/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/docker/docker/labels//tools/logging","name":"/tools/logging","color":"207de5"},{"url":"https://api.github.com/repos/docker/docker/labels/kind/feature","name":"kind/feature","color":"AAB3AB"},{"url":"https://api.github.com/repos/docker/docker/labels/kind/proposal","name":"kind/proposal","color":"bfe5bf"},{"url":"https://api.github.com/repos/docker/docker/labels/roadmap","name":"roadmap","color":"eb6420"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":92,"created_at":"2014-07-23T19:20:31Z","updated_at":"2015-06-22T12:30:48Z","closed_at":"2015-03-31T18:06:54Z","body":"## Improved logging support\r\n \r\n### Topics:\r\n* Logging drivers\r\n* Initial logging drivers\r\n* Default driver improvements\r\n \r\n#### Logging drivers\r\nThe driver interface should be able to support the smallest subset available for logging drivers to\r\nimplement their functionality.  Stdout and stderr will still be the source of logging for containers \r\nin this proposal.  Docker will, however, take the raw streams from the containers and create discrete \r\nmessages delimited by writes.  This parsed struct will then be sent to the logging drivers.\r\n \r\n```go\r\ntype Message struct {\r\n    // ContainerID is the container id where the message originated from\r\n    ContainerID string \r\n \r\n    // RawMessage is the raw bytes from the write\r\n    RawMessage []byte \r\n \r\n    // Source specifies where this message originated, stderr, stdout, syslog\r\n    Source string\r\n \r\n    // Time is the time the message was received\r\n    Time time.Time\r\n \r\n    // Fields are user defined fields attach to the message\r\n    Fields map[string]string\r\n}\r\n \r\ntype Driver interface {\r\n    // Log begins the logging of the stdout and stderr streams for a specific id\r\n    Log(message *Message) error\r\n \r\n    // ReadLog fetches the messages for a specific id\r\n    ReadLog(containerID string) (messages []*Message, err error)\r\n \r\n    // CloseLog tells the driver that no more log messages will be written for the specific id\r\n    // drivers can implement this to their requirements, it may mean compressing the logs or deleting\r\n    // them off of the disk\r\n    CloseLog(containerID string) error\r\n \r\n    // Close ensures that any writes for the logger are properly flushed and can be\r\n    // stopped without data loss\r\n    Close() error\r\n}\r\n```\r\n \r\nWhen creating or initializing the drivers they will be provided with a key/value map with the user defined configuration specific to the driver.  Each driver will also be provided a root directory where it is able to store and manage any type of state on disk.\r\n \r\n \r\n#### Initial logging drivers\r\n \r\n**none** - This driver will ignore the streams and log nothing for the containers.  This is a totally valid\r\ndriver as the docker daemon has to manage the logs for all container it's a memory and performance bottleneck\r\non the daemon.\r\n \r\n**default** - This driver will be the current implementation of logs that docker currently has.  It is a single\r\nfile on disk with json objects with the message, timestamp, and stream of the log message separated by a\r\nnew line char.\r\n \r\n**syslog** - This driver will write to a syslog socket and use the tag field to insert the container id.\r\n \r\n#### Default driver improvements\r\nOne of the biggest issues with the default driver is that there is no log truncation or rotation.  Both of\r\nthese issues need to be addressed.  We can either truncate based on filesize or date.  I believe filesize\r\nis better.\r\n \r\nTruncation size can default to 10mb with an option when you select the driver to specify additional options.\r\nRotation can also be set a specific size limit defaulting to 500mb.  To change the defaults I propose a\r\n`--logging-opt` flag on the daemon, similar to `--storage-opt` for the storage drivers.\r\n \r\n \r\n#### Usage\r\nThe usage for this feature will be managed via the daemon:\r\n \r\n```bash\r\ndocker -d --logging none\r\ndocker -d --logging default --logging-opt truncation=20mb --logging-opt rotation=1gb\r\n```"},"comment":{"url":"https://api.github.com/repos/docker/docker/issues/comments/114086021","html_url":"https://github.com/docker/docker/issues/7195#issuecomment-114086021","issue_url":"https://api.github.com/repos/docker/docker/issues/7195","id":114086021,"user":{"login":"oncletom","id":138627,"avatar_url":"https://avatars.githubusercontent.com/u/138627?v=3","gravatar_id":"","url":"https://api.github.com/users/oncletom","html_url":"https://github.com/oncletom","followers_url":"https://api.github.com/users/oncletom/followers","following_url":"https://api.github.com/users/oncletom/following{/other_user}","gists_url":"https://api.github.com/users/oncletom/gists{/gist_id}","starred_url":"https://api.github.com/users/oncletom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oncletom/subscriptions","organizations_url":"https://api.github.com/users/oncletom/orgs","repos_url":"https://api.github.com/users/oncletom/repos","events_url":"https://api.github.com/users/oncletom/events{/privacy}","received_events_url":"https://api.github.com/users/oncletom/received_events","type":"User","site_admin":false},"created_at":"2015-06-22T12:30:48Z","updated_at":"2015-06-22T12:30:48Z","body":"@psquickitjayant by using `--log-driver=syslog` :-) cf. https://docs.docker.com/reference/run/#logging-drivers-log-driver"}}