Yet another Go logging library with a focus on simplicity and flexibility.
go get github.com/axiomhq/logmanager
package main
import (
"github.com/axiomhq/logmanager"
)
func main() {
// Simple console logger
log := logmanager.GetLogger("foo.bar")
log.Info("hello world")
log.Warn("it's a trap")
// Output:
// [09:15:54.24] info [email protected] main.go:10 hello world
// [09:15:54.24] warn [email protected] main.go:11 it's a trap
}
- Multiple log levels (Trace, Debug, Info, Warning, Error, Critical)
- Colored console output with automatic color assignment per module
- File-based logging with automatic rotation
- Syslog support (RFC 5424)
- Thread-safe operations
- Module-based logging with inheritance
- Stack trace support for errors and panics
- Zero dependencies for core functionality
Set log levels via environment variable:
# Set specific module log levels
export LOGMANAGER_SPEC="foo.bar=Debug:foo=Trace:Info"
# Set global log level
export LOGMANAGER_SPEC="Debug"
logmanager supports multiple output writers:
Outputs colored logs to stdout/stderr with automatic color assignment per module.
writer := logmanager.NewConsoleWriter()
logmanager.AddGlobalWriter(writer)
Writes logs to files with automatic rotation support.
writer := logmanager.NewDiskWriter("/var/log/app.log", logmanager.DiskWriterConfig{
RotateDuration: 24 * time.Hour,
MaximumLogFiles: 7,
})
logmanager.AddGlobalWriter(writer)
Sends logs to syslog (RFC 5424 format).
writer := logmanager.NewSyslogWriter("myapp", "127.0.0.1:514")
logmanager.AddGlobalWriter(writer)