Reputation: 5451
I am trying to write REST services in Go. As there are different frameworks for writing REST service in Go, we would like to do some performance testing before choosing the framework.
Currently I did a sample using go-json-rest. But when I execute this sample REST request, I see the following logs printed in my terminal.
24/Nov/2015:12:30:35 +0530 200 29μs "GET /countries HTTP/1.1" - "Java/1.8.0_45"
This logging will take some time and impact my performance report. How can I switch of this logging?
Upvotes: 0
Views: 252
Reputation: 14769
You should know that it's AccessLogApacheMiddleware that controls your logging, and DefaultDevStack
contains the AccessLogApacheMiddleware
.
Two ways to prevent logging:
AccessLogApacheMiddleware
;...Middlewares
. Since the Use function is a Variadic Functions
, which pass the multiple middlewares into the function. If you don't need AccessLogApacheMiddleware
, you just ignore it. It gives you more power to control whatever middlewares you like.e.g.
api := rest.NewApi()
api.Use(&rest.TimerMiddleware{},
&rest.RecorderMiddleware{},
&rest.PoweredByMiddleware{},
&rest.RecoverMiddleware{})
May this be helpful.
Upvotes: 1