Skip to content

Why are the slow logs still being printed even though the logging has been disabled? #7588

@hyahm

Description

@hyahm

GORM Playground Link

version : v1.30.0

Description

log.SetOutput(ioutil.Discard)
	// 配置日志
	newLogger := logger.New(

		log.New(os.Stdout, "\r\n", log.LstdFlags),
		logger.Config{
			SlowThreshold:             time.Hour,
			LogLevel:                  logger.Silent,
			IgnoreRecordNotFoundError: true,
			Colorful:                  false,
		},
	)

	// 连接主数据库
	dxzgConfig := config.Cfg.Dxzg
	dsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=True&loc=Local",
		dxzgConfig.Username,
		dxzgConfig.Password,
		dxzgConfig.Host,
		dxzgConfig.Port,
		dxzgConfig.DBName,
	)
	var err error
	DB, err = gorm.Open(mysql.Open(dsn), &gorm.Config{
		Logger: newLogger,
	})
	if err != nil {
		panic("failed to connect database")
	}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions