浏览代码

日志文件格式

light 6 月之前
父节点
当前提交
b3a506527e
共有 1 个文件被更改,包括 3 次插入1 次删除
  1. 3 1
      utils/logger.go

+ 3 - 1
utils/logger.go

@@ -4,6 +4,7 @@ import (
 	"os"
 	"os"
 	"path/filepath"
 	"path/filepath"
 	"strings"
 	"strings"
+	"time"
 
 
 	"github.com/natefinch/lumberjack"
 	"github.com/natefinch/lumberjack"
 	"github.com/sirupsen/logrus"
 	"github.com/sirupsen/logrus"
@@ -28,7 +29,8 @@ func InitLogger(logDir string, levelConf string) {
 		panic(err)
 		panic(err)
 	}
 	}
 
 
-	logFile := filepath.Join(logPath, "policy-service.log")
+	currentDate := time.Now().Format("20060102")
+	logFile := filepath.Join(logPath, "policy-service-"+currentDate+".log")
 
 
 	// 配置日志切割
 	// 配置日志切割
 	lumberjackLogger := &lumberjack.Logger{
 	lumberjackLogger := &lumberjack.Logger{