diff --git a/config.yml.sample b/config.yml.sample index ab8a395c..2bb8fc71 100644 --- a/config.yml.sample +++ b/config.yml.sample @@ -76,13 +76,13 @@ log: path: logs # Whether to show any logging at all or none enabled: true - # Where the error log should go. Possible values are stdout, file or off to disable error logging. + # Where the error log should go. Possible values are stdout, stderr, file or off to disable error logging. errors: "stdout" - # Where the normal log should go. Possible values are stdout, file or off to disable standard logging. + # Where the normal log should go. Possible values are stdout, stderr, file or off to disable standard logging. standard: "stdout" - # Whether or not to log database queries. Useful for debugging. Possible values are stdout, file or off to disable database logging. + # Whether or not to log database queries. Useful for debugging. Possible values are stdout, stderr, file or off to disable database logging. database: "off" - # Whether to log http requests or not. Possible values are stdout, file or off to disable http logging. + # Whether to log http requests or not. Possible values are stdout, stderr, file or off to disable http logging. http: "stdout" - # Echo has its own logging which usually is unnessecary, which is why it is disabled by default. Possible values are stdout, file or off to disable standard logging. + # Echo has its own logging which usually is unnessecary, which is why it is disabled by default. Possible values are stdout, stderr, file or off to disable standard logging. echo: "off" \ No newline at end of file diff --git a/docs/config.md b/docs/config.md index e0d28116..97b2772f 100644 --- a/docs/config.md +++ b/docs/config.md @@ -103,21 +103,20 @@ mailer: queuelength: 100 # The timeout in seconds after which the current open connection to the mailserver will be closed. queuetimeout: 30 - + log: # A folder where all the logfiles should go. - path: service.rootpath + "/logs" + path: logs # Whether to show any logging at all or none enabled: true - # Where the error log should go. Possible values are stdout, file or off to disable error logging. + # Where the error log should go. Possible values are stdout, stderr, file or off to disable error logging. errors: "stdout" - # Where the normal log should go. Possible values are stdout, file or off to disable standard logging. + # Where the normal log should go. Possible values are stdout, stderr, file or off to disable standard logging. standard: "stdout" - # Whether or not to log database queries. Useful for debugging. Possible values are stdout, file or off to disable database logging. + # Whether or not to log database queries. Useful for debugging. Possible values are stdout, stderr, file or off to disable database logging. database: "off" - # Whether to log http requests or not. Possible values are stdout, file or off to disable http logging. + # Whether to log http requests or not. Possible values are stdout, stderr, file or off to disable http logging. http: "stdout" - # Echo has its own logging which usually is unnessecary, which is why it is disabled by default. Possible values are stdout, file or off to disable standard logging. + # Echo has its own logging which usually is unnessecary, which is why it is disabled by default. Possible values are stdout, stderr, file or off to disable standard logging. echo: "off" - ``` diff --git a/pkg/log/logging.go b/pkg/log/logging.go index da2259f9..6c0283f9 100644 --- a/pkg/log/logging.go +++ b/pkg/log/logging.go @@ -83,6 +83,7 @@ func InitLogger() { // GetLogWriter returns the writer to where the normal log goes, depending on the config func GetLogWriter(logfile string) (writer io.Writer) { + writer = os.Stderr // Set the default case to prevent nil pointer panics switch viper.GetString("log." + logfile) { case "file": f, err := os.OpenFile(viper.GetString("log.path")+"/"+logfile+".log", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) @@ -91,6 +92,8 @@ func GetLogWriter(logfile string) (writer io.Writer) { } writer = f break + case "stderr": + writer = os.Stderr case "stdout": default: writer = os.Stdout