zap icon indicating copy to clipboard operation
zap copied to clipboard

how to display console recovery log with RecoveryWithZap()

Open smallmenu opened this issue 2 years ago • 1 comments

Hi, When I use default gin.Recovery(), I can set display error into console and write log file:

gin.DefaultErrorWriter = io.MultiWriter(logger, os.Stderr) r.Use(gin.Recovery())

Now,When I use RecoveryWithZap(), it will only write log into the zap logger file,how to display console recovery log too?

Thanks, Best Wishes.

smallmenu avatar Jun 16 '22 08:06 smallmenu

@smallmenu maybe you can setup a dedicated logger for the recovery middleware to use

  • https://github.com/uber-go/zap/issues/586
  • https://stackoverflow.com/questions/50933936/zap-logger-print-both-to-console-and-to-log-file

xuyang2 avatar Jul 05 '22 01:07 xuyang2