I’m writing a REST server in go and wondering what the proper method for logging errors to a /var/log/myservice.log file might be. Specifically, with a service that can be receiving thousands of requests per minute, is there any type of buffering or anything else I need to be concerned about with go?
Can I open a single file handle and pass it around for the different threads to write to or do I need to be handling a different way?
By adding a buffer to the writer is the difference almost zero. However then you will get your log in larger chunks which can be a problem if you want to look at it in realtime.
Thanks for the explanation. I’ve gotten the logger running now and seems to be working well. I obviously don’t write logs out for every transaction, only when there are problems so it shouldn’t really be much of a concern.