slog - Lightweight, configurable, extensible Go logging library
slog - a lightweight, configurable, extensible Go logging library

Features
- Simple, directly available without configuration
- Support common log level processing.
- eg:
tracedebuginfonoticewarnerrorfatalpanic
- eg:
- Support any extension of
HandlerFormatteras needed - Supports adding multiple
Handlerlog processing at the same time, outputting logs to different places - Support to custom log message
Formatter- Built-in
jsontexttwo log record formattingFormatter
- Built-in
- Support to custom build log messages
Handler- The built-in
handler.Confighandler.Buildercan easily and quickly build the desired log handler
- The built-in
- Has built-in common log write handler program
consoleoutput logs to the console, supports color outputwriteroutput logs to the specifiedio.Writerfileoutput log to the specified file, optionally enablebufferto buffer writessimpleoutput log to the specified file, write directly to the file without bufferingrotate_fileoutputs logs to the specified file, and supports splitting files by time and size, andbufferbuffered writing is enabled by default- See ./handler folder for more built-in implementations
Output logs to file
- Support enabling
bufferfor log writing - Support splitting log files by
timeandsize - Support configuration to compress log files via
gzip - Support clean old log files by
BackupNumBackupTime
Git repository
- Github: https://github.com/gookit/slog
- Gitee: https://gitee.com/gookit/slog
Install
Quick start
package main
import (
"github.com/gookit/slog"
)
func main()
output preview:

Logs to file
Using slog to output logs to files is very convenient, and supports multiple files, splitting by time, etc.
package main
import (
"github.com/gookit/slog"
"github.com/gookit/slog/handler"
"github.com/gookit/slog/rotatefile"
)
func main()
See logs dir:
More usage
More usage please see README