|
|
|
Ask HN: How do you make logging consistent
|
|
3 points
by hndl
3597 days ago
|
|
This is a software design question: I have different components which do similar operations (similar, not identical) and I want to normalize the logs that each component emits so I can make diagnosing issues easier. What approach should I take? One thing I have thought about is using an error code for a specific known fault and then emit a message based on the error code (think M$ error codes) - same message parameters for all components but the values differ. I'm more interested in hearing how this has been addressed by HNers who have had to build this functionality. If there are references, please share. |
|
Logging error codes is not a good idea since they add a layer of indirection. The text "file not found" is always clearer than "error code: 412".
Another thing to keep in mind is to make your log messages distinct. If a user reports the error "Connection reset by peer" and there are 28 places in your code which can cause that message, then that is harder to debug than if the error only can be logged from exactly one location.