From dc63e501723890c44c3fcf8bdad5414eea5d5fda Mon Sep 17 00:00:00 2001 From: Jacob Hands Date: Fri, 12 Feb 2016 08:30:47 -0600 Subject: [PATCH] Use rotating log files --- main.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/main.go b/main.go index d83ef09c..ed4449fd 100644 --- a/main.go +++ b/main.go @@ -15,6 +15,7 @@ import ( "github.com/mholt/caddy/caddy" "github.com/mholt/caddy/caddy/https" "github.com/xenolf/lego/acme" + "gopkg.in/natefinch/lumberjack.v2" ) var ( @@ -65,11 +66,12 @@ func main() { case "": log.SetOutput(ioutil.Discard) default: - file, err := os.OpenFile(logfile, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0644) - if err != nil { - log.Fatalf("Error opening process log file: %v", err) - } - log.SetOutput(file) + log.SetOutput(&lumberjack.Logger{ + Filename: logfile, + MaxSize: 100, + MaxAge: 14, + MaxBackups: 10, + }) } if revoke != "" {