2 ms·
> Make it the top layer’s responsibility and don’t log in any services or lower level code. > Make sure your logging framework is including stack traces so you
by quicklime 3y ago
> Make it the top layer’s responsibility and don’t log in any services or lower level code.
> Make sure your logging framework is including stack traces so you can trace the error to its cause.
> For example in a web app you would log the error in the http handler when returning the Internal Server status code.
This is different from how I do it, am I doing anything wrong?
I prefer to make it the bottom layer’s responsibility - so, the first source of the error at the boundary of my application and the library that produces the error, rather than the top level of the http handler.
Go errors infamously don’t include stack traces, so how are you supposed to know where your error originated from if you log it from the top level of the http handler?