Logger
Logger Introduction
High-performance structured logger for Go built on top of log/slog.
Focused on minimal allocations, high performance, and simple file rotation while staying compatible with the Go standard logging ecosystem.
Use logger to combine colorized console output, JSON logging, file rotation, and daily log archiving through a clean slog-compatible API.
Features
- Standard Compatible: Built directly on top of Go’s standard
log/slogpackage - Colorized Terminal Output: Human-readable colored logs for local development
- Structured JSON Logging: Machine-friendly JSON logs for production environments
- Automatic Log Directory: Creates the default
logdirectory automatically - File Rotation: Daily and size-based log rotation support
- Automatic Cleanup: Removes old archived log files automatically
- Daily Log Naming: Generates files such as
2026-05-11-0001.log - Separate Log Levels: Independent minimum levels for terminal and file output
- Custom Notice Level: Includes
LevelNoticesupport for important console-visible messages - Context Logging: Supports
InfoContext,WarnContext, andErrorContext - Structured Chaining: Reusable structured loggers with
logger.With(...) - Source Tracking: Optional source file and line number logging
- Thread-Safe Design: Safe for concurrent workloads and server environments
- Optimized File Writer: High-throughput logging with reduced allocation overhead
- Graceful Shutdown: Safe logger shutdown through the returned
Closer
Requirements
This package requires Go 1.22 or newer.
It is designed for modern Go projects and may use language and standard library features introduced in recent Go versions.
- Go:
1.22or newer - Dependencies: Standard library only
- Features used: Generics, concurrency primitives