slog is a free, open source monitoring & observability project written in Rust and released under Apache-2.0. It has 1,706 GitHub stars, 98 forks and 57 open issues, and was last pushed 5 months ago. On this registry it ranks #188 of 270 tracked projects in Monitoring & Observability, with 5 head-to-head comparisons available.

What is slog?

slog is an ecosystem of reusable components for structured, contextual, extensible and composable logging in Rust, built for Rust developers and teams who need more than the standard log crate provides.

What it is

slog is the core of a logging ecosystem rather than a single library. The core crate defines structured logging with contextual data attached to every event, and the real output functionality lives in separate feature crates such as slog-term for terminal output, slog-async for asynchronous logging, slog-json for JSON output and slog-syslog for syslog. It is hosted under the slog-rs GitHub organization, maintained by original author Dawid Ciężarkiewicz, carries the slog-rs and structured-logging topics, and is published under the Apache-2.0 licence with documentation generated on docs.rs.

The concrete problem it solves is the ceiling of the standard Rust log crate. slog's stated ambition is that if a feature is missing from log, slog should have it, which means structured rather than flat records, contextual and hierarchical loggers, and composable output back ends instead of one fixed destination. The README is explicit that this power comes with a steeper learning curve, and that new feature crates are easy to write and publish, so the ecosystem grows with the requirements of its users.

Key capabilities

  • Core structured logging API with the ecosystem's functionality split into feature crates such as slog-term, slog-async, slog-json and slog-syslog.
  • slog-term terminal output with automatic TTY detection, colors, and both compact and full output modes.
  • slog-async for asynchronous logging, so formatting and output do not block the calling thread.
  • slog-json for JSON log output and slog-syslog for logging to syslog.
  • sloggers, a third-party wrapper library providing convenience methods for quicker setup.
  • Hierarchical and contextual logging, with structured key-value context carried through log records.
  • Auto-generated feature and API documentation hosted at docs.rs/slog, with a full overview in examples/features.rs.

Who uses it and how

  • Rust projects whose workloads do not use async, where slog's synchronous model is a natural fit.
  • Teams that consider a mature, stable and battle-tested code base and API a plus over newer alternatives.
  • Applications that need capabilities the competing tracing ecosystem is missing.
  • Projects that want contextual and hierarchical logging, where context is attached once and carried through nested loggers.
  • Crate authors who publish their own slog feature crates on crates.io, including third-party efforts such as sloggers.

Getting started

Add the slog core crate from crates.io together with the feature crates needed for the chosen output, such as slog-term or slog-json. Full code overview is in examples/features.rs, API details are at docs.rs/slog, and help is available through the slog-rs Gitter channel.

How it compares

Among similar tools, the README names the standard log crate as the library slog extends beyond, and tracing as the competing Rust ecosystem that is already a go-to solution and has better async debugging support plus a larger dev team and community. The README itself recommends considering tracing first, listing cases where slog still fits better: no async benefit, preference for mature and stable code and API, features tracing lacks, and strong performance.

When to use it — and when not to

slog is a library rather than a service, so nothing like a database, object storage or SMTP server has to be operated, but adopters do take on the steeper learning curve and an ecosystem split across many feature crates. Because the README states that the code is reliable while the documentation sometimes could use improvement, expect to read docs.rs pages and ask in the Gitter channel rather than rely on prose guides. Developers working in async-heavy code should not pick slog, since the project's own README points them to tracing.

project readme (upstream, from github) — read inline

slog-rs logo
GH Actions (Cargo Test) slog-rs on crates.io slog-rs Gitter Chat docs-rs: release versions documentation
Getting started Introduction FAQ
Crate list

slog-rs - The Logging for Rust

You might consider using tracing instead

It's been a while since slog was created and it served Rust community well all this time. It remains a stable, featureful and battle-tested library, used in many important projects.

In last few years, another ecosystem for Rust was created with similar features and a very good support for debugging async code and already larger dev team and community.

Please check tracing and see if it is more suitable for your use-case. It seems that it is already a go-to logging/tracing solution for Rust.

Reasons you might want to stick with slog anyway:

  • async support doesn't benefit you
  • you consider mature, stable code & API a plus
  • it has some features that tracing is missing
  • great performance (I have NOT done any comparison, but slog's performance is very good).

Introduction (please read)

slog is an ecosystem of reusable components for structured, extensible, composable and contextual logging for Rust.

The ambition is to be The Logging Library for Rust. slog should accommodate a variety of logging features and requirements. If there is a feature that you need and standard log crate is missing, slog should have it.

This power comes with a little steeper learning curve, so if you experience any problems, please join slog-rs gitter channel to get up to speed. If you'd like to take a quick, convenient route, consider using sloggers wrapper library.

While the code is reliable, the documentation sometimes could use an improvement. Please report all issues and ideas.

Features & technical documentation

Most of the interesting documentation is auto-generated and hosted on https://docs.rs.

Go to docs.rs/slog to read about features and APIs (examples included).

Note: slog is just a core, and the actual functionality is inside many feature crates. To name a few:

There are many more slog feature crates. Search for more slog features on crates.io. It is easy to write and publish new ones. Look through all the existing crates using slog for examples and ideas.

Terminal output example

slog-term is only one of many slog features - useful showcase, multi-platform, and featuring eg. automatic TTY detection and colors.

See following screenshot: same output in both compact and full output mode.

slog-rs terminal example output

Using & help

Please use slog-rs gitter channel to ask for help or discuss slog features.

See examples/features.rs for full quick code example overview.

Read Documentation for details and features.

To report a bug or ask for features use github issues.

Slog community

Slog related crates are hosted under slog github organization.

Dawid Ciężarkiewicz is the original author and current maintainer of slog and therefore self-appointed benevolent dictator over the project. When working on slog Dawid follows and expects everyone to follow his Code of Conduct.

Any particular repositories under slog ecosystem might be created, controlled, maintained by other entities with various levels of autonomy. Lets work together toward a common goal in a respectful and welcoming atmosphere!

Verification Recommendation

To help with the maintained, the ownership of this crate is potentially shared between multiple developers. It is recommended to always use cargo-crev to verify the trustworthiness of each of your dependencies, including this one.

Frequently asked questions

Is slog free to use?

slog is open source under the Apache-2.0 licence. There is no licence fee and no seat count — you can self-host it or, where the project offers one, pay a vendor for a managed version instead.

What does slog do?

Structured, contextual, extensible, composable logging for Rust

What is slog written in?

slog is primarily written in Rust. Its source is publicly available at https://github.com/slog-rs/slog, and it has 1,706 GitHub stars.