Repolode
sirupsen

sirupsen/logrus

Structured, API-compatible logger for Go with pluggable formatters and hooks, now in maintenance mode.

Stars
25,764
Forks
2,297
Open issues
59
Last commit
22 days ago

What is it?

Logrus is a structured logger for Go that is API-compatible with the standard library's log package, so existing log imports can be swapped over with little change. It writes entries with key-value fields and a level, and can output colored text for terminals, logfmt-style text, or JSON for log aggregation systems such as Logstash and Splunk.

The logger supports seven levels from Trace to Panic, per-logger output destinations via any io.Writer, and reusable field contexts created with WithFields. Hooks let entries be forwarded elsewhere, such as error trackers or syslog, and custom formatters can be added by implementing a Format method. Caller reporting, a test hook for asserting logged messages, and fatal exit handlers are also included.

The project is in maintenance mode: the maintainers focus on security fixes, bug fixes and performance, with new features limited to interoperability such as Go's log/slog. The README points to Zerolog, Zap and Apex as alternatives designed with newer Go structured-logging practices.

Key features

  • 01Drop-in compatible with the standard library log API.
  • 02Structured key-value fields with seven levels from Trace to Panic.
  • 03Colored terminal output, logfmt-style text, and JSON formatters.
  • 04Hooks for forwarding entries to services such as syslog or error trackers.
  • 05Custom formatters via a simple Format interface.
  • 06Test hook for asserting logged messages in unit tests.

Use cases

  • Adding structured JSON logs to a Go service for ingestion by Logstash or Splunk.
  • Migrating an existing project from the standard log package without rewriting call sites.
  • Sending error-level entries to an external exception tracker through a hook.
  • Asserting in unit tests that specific log messages were emitted.

Quick start

  1. 1

    Install the Logrus module

    go get github.com/sirupsen/logrus
  2. 2

    Import it in your Go code and log a message with fields

Things to know

  • Logrus is in maintenance mode, so no new features are planned.
  • Its README points to alternatives such as Zerolog, Zap and Apex.

In collections

Topics

FAQ

What is logrus?
Structured, API-compatible logger for Go with pluggable formatters and hooks, now in maintenance mode. Logrus is a structured logger for Go that is API-compatible with the standard library's log package, so existing log imports can be swapped over with little change. It writes entries with key-value fields and a level, and can output colored text for terminals, logfmt-style text, or JSON for log aggregation systems such as Logstash and Splunk.
Is logrus free to use? What license does it have?
logrus is open source under the MIT license. Check the license terms before using it in commercial products.
Is logrus still maintained?
Actively maintained. The last commit to logrus was on Oct 2, 2026.
What can I use logrus for?
Adding structured JSON logs to a Go service for ingestion by Logstash or Splunk. Migrating an existing project from the standard log package without rewriting call sites. Sending error-level entries to an external exception tracker through a hook. Asserting in unit tests that specific log messages were emitted.
How do I install logrus?
Install the Logrus module: go get github.com/sirupsen/logrus Import it in your Go code and log a message with fields
Where can I get logrus?
The source code and installation instructions are on GitHub: https://github.com/sirupsen/logrus

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects