|
@@ -13,6 +13,7 @@ import (
|
|
|
"github.com/docker/docker/daemon/logger/jsonfilelog"
|
|
|
"github.com/docker/docker/pkg/ioutils"
|
|
|
"github.com/docker/docker/pkg/stdcopy"
|
|
|
+ containertypes "github.com/docker/engine-api/types/container"
|
|
|
timetypes "github.com/docker/engine-api/types/time"
|
|
|
)
|
|
|
|
|
@@ -103,7 +104,7 @@ func (daemon *Daemon) getLogger(container *container.Container) (logger.Logger,
|
|
|
if container.LogDriver != nil && container.IsRunning() {
|
|
|
return container.LogDriver, nil
|
|
|
}
|
|
|
- cfg := container.GetLogConfig(daemon.defaultLogConfig)
|
|
|
+ cfg := daemon.getLogConfig(container.HostConfig.LogConfig)
|
|
|
if err := logger.ValidateLogOpts(cfg.Type, cfg.Config); err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
@@ -112,7 +113,7 @@ func (daemon *Daemon) getLogger(container *container.Container) (logger.Logger,
|
|
|
|
|
|
// StartLogging initializes and starts the container logging stream.
|
|
|
func (daemon *Daemon) StartLogging(container *container.Container) error {
|
|
|
- cfg := container.GetLogConfig(daemon.defaultLogConfig)
|
|
|
+ cfg := daemon.getLogConfig(container.HostConfig.LogConfig)
|
|
|
if cfg.Type == "none" {
|
|
|
return nil // do not start logging routines
|
|
|
}
|
|
@@ -137,3 +138,16 @@ func (daemon *Daemon) StartLogging(container *container.Container) error {
|
|
|
|
|
|
return nil
|
|
|
}
|
|
|
+
|
|
|
+// getLogConfig returns the log configuration for the container.
|
|
|
+func (daemon *Daemon) getLogConfig(cfg containertypes.LogConfig) containertypes.LogConfig {
|
|
|
+ if cfg.Type != "" || len(cfg.Config) > 0 { // container has log driver configured
|
|
|
+ if cfg.Type == "" {
|
|
|
+ cfg.Type = jsonfilelog.Name
|
|
|
+ }
|
|
|
+ return cfg
|
|
|
+ }
|
|
|
+
|
|
|
+ // Use daemon's default log config for containers
|
|
|
+ return daemon.defaultLogConfig
|
|
|
+}
|