🎨 优化日志文件名,新增主机名
This commit is contained in:
parent
40a3dc9339
commit
16775ae2ab
4
file.go
4
file.go
@ -5,13 +5,15 @@ import (
|
||||
"github.com/natefinch/lumberjack"
|
||||
"go.uber.org/zap"
|
||||
"go.uber.org/zap/zapcore"
|
||||
"os"
|
||||
"time"
|
||||
)
|
||||
|
||||
// 初始化LokiCore,使日志可以输出到文件
|
||||
func initFileCore() zapcore.Core {
|
||||
hostname, _ := os.Hostname()
|
||||
lumberJackLogger := &lumberjack.Logger{
|
||||
Filename: "logs/runtime.log", // 日志文件的位置
|
||||
Filename: fmt.Sprintf("logs/runtime-%s.log", hostname), // 日志文件的位置
|
||||
MaxSize: 10, // 最大10M
|
||||
MaxBackups: 5, // 保留旧文件的最大个数
|
||||
MaxAge: 30, // 保留旧文件的最大天数
|
||||
|
Loading…
Reference in New Issue
Block a user