Chapter 10.
Structured Logging and Error Handling
In this section of the book, we’re going to take a short break from working on our API endpoints and focus on making some improvements to the way that we handle exceptions and errors.
You’ll learn how to:
- Create a custom logger for writing structured, levelled, log messages in JSON format.
- Integrate the custom logger with your handlers and Go’s
http.Server, so that all log messages are written to one location in a consistent format. - How to recover and gracefully handle panics in your application middleware and handlers.