Gin: Document how to disable the request log

Created on 20 Apr 2016  路  7Comments  路  Source: gin-gonic/gin

Even with GIN_MODE=release, gin still prints the full request log to console, which can seriously slow down performance.

We've had to disable it temporarily during performance testing by redirecting it to /dev/null.

Please document how to properly enable/disable the request log.

Thank you

Most helpful comment

Do you use gin.Default() ? If so you have to use gin.New() and add the recovery middleware (if you still want it) because gin.Default() add the Logger and Recovery middleware.

All 7 comments

Do you use gin.Default() ? If so you have to use gin.New() and add the recovery middleware (if you still want it) because gin.Default() add the Logger and Recovery middleware.

Ah, I see. It's probably worth documenting that to be more explicit.

Thank you for the explanation.

It is documented in README.

Thats not documented very well. That doesnt explain what the logger or recovery middleware are.

See the PR https://github.com/gin-gonic/gin/pull/1056 improve the document.

@zirkome Even using Default() still prints out pretty verbose message when using it in unit tests. Maybe I am doing something wrong ?

@ldelossa That's the thing the gin.Default() function includes a logger by default. If you want to control the logging you should use a custom Gin router with gin.New() and add whatever global middleware you want/need.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wangcn picture wangcn  路  3Comments

ccaza picture ccaza  路  3Comments

mdnight picture mdnight  路  3Comments

olegsobchuk picture olegsobchuk  路  3Comments

sofish picture sofish  路  3Comments