github.com/sirupsen/logrus
This package has a good security score with no known vulnerabilities.
Community Reviews
Solid structured logging but watch for secret leakage and reflection overhead
From a security perspective, logrus has concerning defaults. Fields are logged verbatim without sanitization, making it trivial to accidentally log credentials, tokens, or PII if you're not careful with WithField calls. There's no built-in redaction or sensitive field filtering. Error wrapping can expose stack traces with internal paths in production if you don't configure the formatter carefully.
The reflection-based field handling adds overhead and makes it harder to audit what's being logged at compile time. Hook support is useful but hooks receive all log entries, creating risk if a hook mishandles sensitive data. TLS isn't directly relevant here, but the library doesn't provide guidance on secure logging practices, which would be valuable given how often logs become attack vectors.
Best for: Existing projects already using logrus where migration cost outweighs benefits and you have strict logging hygiene practices.
Avoid if: You're starting a new Go project or need built-in compliance features like automatic PII redaction.
Functional but showing its age - structured logging with ergonomic tradeoffs
However, daily use reveals friction points. The package uses a global logger by default, which creates testing headaches and makes dependency injection awkward. You'll spend time creating logger instances and passing them through constructors. Type safety is weak - Fields is just `map[string]interface{}`, so typos in field names go unnoticed until runtime, and there's no autocomplete for your structured fields.
The project is in maintenance mode now, and it shows. No support for structured logging with type-safe fields like newer libraries offer. Performance under high load is noticeably slower than slog or zap. The API works fine for small services, but you'll hit walls as complexity grows.
Best for: Existing projects already using Logrus or small services where performance isn't critical and you value API familiarity.
Avoid if: You're starting a new project - use stdlib's slog instead for better performance, type safety, and long-term support.
Battle-tested but showing its age - consider slog for new projects
The biggest daily annoyance is performance - liberal use of reflection and interface{} types mean allocation-heavy logging that shows up in profiles. The global logger pattern encourages coupling that makes testing harder. Hook management becomes cumbersome in larger applications, and the formatter interface requires more boilerplate than modern alternatives.
Type safety is minimal - Fields accept interface{} values, so you lose compile-time guarantees and IDE assistance. Error messages are basic, and when formatters fail, debugging can be opaque. With Go 1.21+ including slog in the standard library, Logrus feels like technical debt waiting to happen, though it remains perfectly functional for existing codebases.
Best for: Maintaining existing projects already using Logrus where migration cost outweighs benefits.
Avoid if: Starting new projects in Go 1.21+ where slog provides better performance and first-class support.
Sign in to write a review
Sign In