From 4459f76a17f300cca2e905b10aa5035191412848 Mon Sep 17 00:00:00 2001 From: Minho Date: Fri, 2 Jun 2017 16:29:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DBUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- commands/command.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/commands/command.go b/commands/command.go index 63d00776..662dd81d 100644 --- a/commands/command.go +++ b/commands/command.go @@ -20,6 +20,7 @@ import ( "github.com/lifei6671/godoc/models" "github.com/lifei6671/godoc/utils" "log" + "encoding/json" ) var ( @@ -90,11 +91,16 @@ func RegisterLogger(log string) { if _, err := os.Stat(logPath); os.IsNotExist(err) { os.MkdirAll(log, 0777) - logPath = strings.Replace(logPath,"\\","/","") if f, err := os.Create(logPath); err == nil { f.Close() - beego.SetLogger("file", fmt.Sprintf(`{"filename":"%s"}`, logPath)) + config := make(map[string]interface{},1) + + config["filename"] = logPath + + b,_ := json.Marshal(config) + + beego.SetLogger("file", string(b)) } }