Commit 2dba4432 authored by Matt Holt's avatar Matt Holt

Merge pull request #600 from jacobhands/betterlogging

Rotate process log
parents cae9f7de dc63e501
...@@ -15,6 +15,7 @@ import ( ...@@ -15,6 +15,7 @@ import (
"github.com/mholt/caddy/caddy" "github.com/mholt/caddy/caddy"
"github.com/mholt/caddy/caddy/https" "github.com/mholt/caddy/caddy/https"
"github.com/xenolf/lego/acme" "github.com/xenolf/lego/acme"
"gopkg.in/natefinch/lumberjack.v2"
) )
var ( var (
...@@ -65,11 +66,12 @@ func main() { ...@@ -65,11 +66,12 @@ func main() {
case "": case "":
log.SetOutput(ioutil.Discard) log.SetOutput(ioutil.Discard)
default: default:
file, err := os.OpenFile(logfile, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0644) log.SetOutput(&lumberjack.Logger{
if err != nil { Filename: logfile,
log.Fatalf("Error opening process log file: %v", err) MaxSize: 100,
} MaxAge: 14,
log.SetOutput(file) MaxBackups: 10,
})
} }
if revoke != "" { if revoke != "" {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment