aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMatthew Holt <[email protected]>2017-04-18 16:01:11 -0600
committerMatthew Holt <[email protected]>2017-04-18 16:01:11 -0600
commit1e8ab1cadf757247f6c086b47f28a0f09e0bf188 (patch)
tree49433112f513b7526d2ec6cec7fe21b61349bbf4
parent729e4f0239528e1c2ac2f64207aef769564fc697 (diff)
downloadcaddy-1e8ab1cadf757247f6c086b47f28a0f09e0bf188.tar.gz
caddy-1e8ab1cadf757247f6c086b47f28a0f09e0bf188.zip
httpserver: Don't close stdout or stderr when closing logs (fix #1471)
-rw-r--r--caddyhttp/httpserver/logger.go8
1 files changed, 5 insertions, 3 deletions
diff --git a/caddyhttp/httpserver/logger.go b/caddyhttp/httpserver/logger.go
index f16042c03..29e888a5c 100644
--- a/caddyhttp/httpserver/logger.go
+++ b/caddyhttp/httpserver/logger.go
@@ -91,17 +91,14 @@ selectwriter:
switch l.Output {
case "", "stderr":
l.writer = os.Stderr
-
case "stdout":
l.writer = os.Stdout
-
case "syslog":
l.writer, err = gsyslog.NewLogger(gsyslog.LOG_ERR, "LOCAL0", "caddy")
if err != nil {
return err
}
default:
-
if address := parseSyslogAddress(l.Output); address != nil {
l.writer, err = gsyslog.DialLogger(address.network, address.address, gsyslog.LOG_ERR, "LOCAL0", "caddy")
@@ -136,6 +133,11 @@ selectwriter:
// Close closes open log files or connections to syslog.
func (l *Logger) Close() error {
+ // don't close stdout or stderr
+ if l.writer == os.Stdout || l.writer == os.Stderr {
+ return nil
+ }
+
// Will close local/remote syslog connections too :)
if closer, ok := l.writer.(io.WriteCloser); ok {
l.fileMu.Lock()