GORM Playground Link

https://github.com/go-gorm/gorm/commit/9eec6ae06638665661f9872e783a42613527e146

Description

Our service has its own log level and log format, but we found gorm's output in our standard output, and we tried to replace gorm's default logging with gorm.Config.Logger. But it does not work correctly.

After reading the code, we found the following code which seems to be faulty:

https://github.com/go-gorm/gorm/blob/eae73624ad43384d34ee0c9f85055b1fe48434b1/finisher_api.go#L454

A new Config was created in DB.Scan, using the default logger.Recorder, with a reference to logger.Default behind it.

Although the logger for tx is restored at the end, tx.Rows() -> tx.callbacks.Row().Execute(tx) -> db.Logger.Trace(...) outputs the log before that:

https://github.com/go-gorm/gorm/blob/eae73624ad43384d34ee0c9f85055b1fe48434b1/callbacks.go#L134

Comment From: github-actions[bot]

The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 2 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking