Open
Description
Describe the bug
After rotation (creation of a new file) the very first log line is skipped and is not showing in log file.
To Reproduce
`func initiliaselogger() {
level := getLevel(env.ENV.LOG_LEVEL)
devConfig := zap.NewDevelopmentEncoderConfig()
prodConfig := zap.NewProductionEncoderConfig()
devConfig.EncodeTime = zapcore.RFC3339NanoTimeEncoder
prodConfig.EncodeTime = zapcore.RFC3339NanoTimeEncoder
hostname, err := os.Hostname()
if err != nil {
hostname = ""
}
if hostname != "" {
hostname = "_" + hostname
}
filewriter := zapcore.AddSync(&lumberjack.Logger{
Filename: "logs/regulatory/" + strings.ToLower(strings.ReplaceAll(env.ENV.PROCESS_NAME+hostname, " ", "_")) + ".log",
MaxSize: 40,
MaxAge: 30,
MaxBackups: 100,
Compress: false, // disabled by default
})
core := zapcore.NewCore(zapcore.NewJSONEncoder(prodConfig), filewriter, level)
if env.ENV.ENVIRONMENT == "dev" {
core = zapcore.NewTee(
core,
zapcore.NewCore(zapcore.NewConsoleEncoder(devConfig), zapcore.Lock(os.Stdout), level),
)
}
if env.ENV.KAFKA_LOG == "Y" {
kafkaSync := zapcore.AddSync(getKafkaWriter())
core = zapcore.NewTee(
core,
zapcore.NewCore(zapcore.NewJSONEncoder(prodConfig), kafkaSync, level),
)
}
Log = zap.New(core,
zap.AddCaller(),
zap.AddCallerSkip(1),
zap.AddStacktrace(zap.ErrorLevel),
)
}`
Expected behavior
After the creation of a new file (after rotation), the very line of the log is skipped.
Pls let me know if I have to change anything in the configuration while initializing the logger.
Metadata
Assignees
Labels
No labels
Activity