Gin: Can I disable gin's stdout?

Created on 24 Apr 2015  路  10Comments  路  Source: gin-gonic/gin

Hi,

Now I am using a lot on gin. And now I wonder if I can disable gin's stdout ?

If there is some , then how?

Thanks.

question

Most helpful comment

@allencloud

Try this:

gin.SetMode(gin.ReleaseMode)
gin.DefaultWriter = ioutil.Discard

All 10 comments

Just initialize gin with New instead of Default. I assume you're talking about the Logger middleware.

gin.New()
r.Use(gin.Recovery())

Yes, I do not hope to use Stdout but Logger middleware instead. Thank you very much.

Well the Logger is always going to write to stdout. Unless you redirect the output to a file, or use something like supervisord. If you want to write to a specific file without redirection you'd have to write your own Logger middleware.

@allencloud this might be the droid you are looking for:

gin.SetMode(gin.ReleaseMode)

Took me weeks before i found it :)

Thanks a lot @nazwa . It works perfectly. :)

$ export GIN_MODE=release

@allencloud

Try this:

gin.SetMode(gin.ReleaseMode)
gin.DefaultWriter = ioutil.Discard

@allencloud

Try this:

gin.SetMode(gin.ReleaseMode)
gin.DefaultWriter = ioutil.Discard

Works perfectly!!!!! thanks

// init gin.Engine like this
engine = gin.Default()
engine.RouterGroup.Handlers = engine.RouterGroup.Handlers[0:0]
engine.Use(gin.Recovery())

// init gin.Engine like this engine = gin.Default() engine.RouterGroup.Handlers = engine.RouterGroup.Handlers[0:0] engine.Use(gin.Recovery())

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sofish picture sofish  路  3Comments

olegsobchuk picture olegsobchuk  路  3Comments

ccaza picture ccaza  路  3Comments

lilee picture lilee  路  3Comments

kekemuyu picture kekemuyu  路  3Comments