Browse Source

Fixed bug that log soft link can not point to the correct log file

main
Granty1 5 years ago
parent
commit
a5297fd663
  1. 2
      server/config.yaml
  2. 8
      server/core/log.go

2
server/config.yaml

@ -47,4 +47,4 @@ log:
prefix: '[GIN-VUE-ADMIN]' prefix: '[GIN-VUE-ADMIN]'
log-file: true log-file: true
stdout: 'DEBUG' stdout: 'DEBUG'
file: 'WARNING'
file: 'DEBUG'

8
server/core/log.go

@ -15,7 +15,7 @@ import (
const ( const (
logDir = "log" logDir = "log"
logSoftLink = "api.log"
logSoftLink = "latest_log"
module = "gin-vue-admin" module = "gin-vue-admin"
) )
@ -56,11 +56,11 @@ func registerFile(c config.Log, backends []oplogging.Backend) []oplogging.Backen
fmt.Println("create log directory") fmt.Println("create log directory")
_ = os.Mkdir(logDir, os.ModePerm) _ = os.Mkdir(logDir, os.ModePerm)
} }
apiLogPath := logDir + string(os.PathSeparator) + logSoftLink
//apiLogPath := logSoftLink
fileWriter, err := rotatelogs.New( fileWriter, err := rotatelogs.New(
apiLogPath+".%Y-%m-%d-%H-%M.log",
logDir+string(os.PathSeparator)+"%Y-%m-%d-%H-%M.log",
// generate soft link, point to latest log file // generate soft link, point to latest log file
rotatelogs.WithLinkName(apiLogPath),
rotatelogs.WithLinkName(logSoftLink),
// maximum time to save log files // maximum time to save log files
rotatelogs.WithMaxAge(7*24*time.Hour), rotatelogs.WithMaxAge(7*24*time.Hour),
// time period of log file switching // time period of log file switching

Loading…
Cancel
Save