package main import ( "gopkg.in/natefinch/lumberjack.v2" "io" "log" "os" ) // 日志生成文件,配置初始化 func logInitial() { multiWriter := io.MultiWriter(os.Stdout, &lumberjack.Logger{ Filename: "./logs/logInfo.log", MaxSize: 1, // megabytes MaxBackups: 10, MaxAge: 30, //days //Compress: true, }) log.SetFlags(log.LstdFlags | log.Lshortfile) log.SetOutput(multiWriter) log.Println("=================log start=================") log.Println("==>") }