We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
Structured Logging for the Standard Library - Jonathan Amsterdam
Improve logging performance in Go with Structured Logging: a fast, efficient, and simple solution aimed at making the standard library's default logger.
- Structured logging is proposed for the Go standard library to improve logging performance.
- Memory allocation is a significant obstacle to efficient logging.
- Logging should be done simply, with no unnecessary complexity.
-
The proposed
Slog
library aims to provide a fast and efficient way to log. - Zap, a structured logging library, is used as a reference point.
-
The
Slog
logger uses a simple and static approach to logging. - The logger creates a record that can be used to produce log lines.
- The record includes the time, level, and message.
- Handlers are used to produce log lines from records.
- A pool of handlers is used to avoid memory allocation.
-
The
Slog
logger is used as a replacement for the standard Go log package. - The goal is to make the logger easy to use and safe.
-
The default logger is set to the
Slog
logger. -
The
Slog
logger is designed to be fast and efficient. - The logger creates a record and then calls the handle method.
- The handle method produces the log line.
-
The
Slog
logger is tested and compared to Zap. -
The results show that
Slog
is faster than Zap. -
The
Slog
logger is included in the Go standard library.