From 51f6ed9bff03e29079d9a7774905312877e2fa0a Mon Sep 17 00:00:00 2001 From: ti-srebot <66930949+ti-srebot@users.noreply.github.com> Date: Wed, 9 Feb 2022 14:03:35 +0800 Subject: [PATCH] [logutil]: Fix `MaxDays` and `MaxBackups` not working for slow-query-logger (#27625) (#30171) ref pingcap/tidb#25716 --- util/logutil/slow_query_logger.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/util/logutil/slow_query_logger.go b/util/logutil/slow_query_logger.go index c64333afd9baf..cf03dd34e6b80 100644 --- a/util/logutil/slow_query_logger.go +++ b/util/logutil/slow_query_logger.go @@ -15,17 +15,15 @@ var _pool = buffer.NewPool() func newSlowQueryLogger(cfg *LogConfig) (*zap.Logger, *log.ZapProperties, error) { - // copy global config and override slow query log file - // if slow query log filename is empty, slow query log will behave the same as global log + // copy the global log config to slow log config + // if the filename of slow log config is empty, slow log will behave the same as global log. sqConfig := cfg.Config // level of the global log config doesn't affect the slow query logger which determines whether to // log by execution duration. sqConfig.Level = LogConfig{}.Level if len(cfg.SlowQueryFile) != 0 { - sqConfig.File = log.FileLogConfig{ - MaxSize: cfg.File.MaxSize, - Filename: cfg.SlowQueryFile, - } + sqConfig.File = cfg.File + sqConfig.File.Filename = cfg.SlowQueryFile } // create the slow query logger