#json-logging #actix-web #structured #logging #log

actix-slog

structured access-logging for actix-web utilizing slog, thus enabling JSON-logging

3 unstable releases

0.2.1 Sep 25, 2020
0.2.0 Sep 14, 2020
0.1.0 Jul 6, 2020

#1118 in HTTP server

Download history 23/week @ 2024-07-19 39/week @ 2024-07-26 34/week @ 2024-08-02 47/week @ 2024-08-09 31/week @ 2024-08-16 33/week @ 2024-08-23 21/week @ 2024-08-30 53/week @ 2024-09-06 36/week @ 2024-09-13 39/week @ 2024-09-20 34/week @ 2024-09-27 34/week @ 2024-10-04 23/week @ 2024-10-11 37/week @ 2024-10-18 43/week @ 2024-10-25 64/week @ 2024-11-01

176 downloads per month
Used in pslink

MIT/Apache

23KB
199 lines

Rust build crates.io badge docs.rs badge

Structured (access-) logging for actix-web

Provides a middleware (StructuredLogger), similar to actix_web::middleware:Logger, except that it uses slog and thus enables JSON-formatted logging (via slog-json).

Of course slog's compact terminal output is a nice add-on, even if you're just out for JSON-logging.

Usage

See server_json and server_compact for working examples.

  let logger: slog::Logger = unimplemented!();

  HttpServer::new(move || {
    App::new()
      .wrap(
        StructuredLogger::new(logger.new(o!("log_type" => "access"))),
      )
    })
    .bind("[::1]:8080")

Dependencies

~32MB
~637K SLoC