slog-redis

Crates.ioslog-redis
lib.rsslog-redis
version0.1.2
sourcesrc
created_at2020-10-03 17:18:54.649537
updated_at2021-04-25 20:48:16.677499
descriptionRedis drain for slog-rs
homepagehttps://github.com/bolcom/unFTP/tree/master/crates/redislog
repositoryhttps://github.com/bolcom/unFTP/tree/master/crates/redislog
max_upload_size
id295828
size17,883
unFTP (github:bolcom:unftp)

documentation

https://docs.rs/slog-redis

README

slog-redis

This crate implements a slog drain that outputs to a Redis list.

Useful for centralized logging using a RELK stack (Redis, Elasticsearch, Logstash and Kibana). All log messages are sent to a Redis server, in Logstash message V0 format, ready to be parsed/processed by Logstash.

The format looks like this:

 {
    "@timestamp": ${timeRFC3339},
    "@source_host": ${hostname},
    "@message": ${message},
    "@fields": {
       "level": ${levelLowercase},
       "application": ${appName}
       ... // logged field 1
       ... // logged field 2
       ...
   }

Example Usage:

 use slog::*;
 use slog_redis::Builder;

 let redis_drain = Builder::new("my-app-name")
   .redis_host("localhost")
   .redis_key("my_redis_list_key")
   .build()
   .unwrap();

 let drain = slog_async::Async::new(redis_drain.fuse()).build().fuse();

 let log = Logger::root(drain, o!());
 info!(log, "Send me to {}!", "Redis"; "msg" => "Hello World!");
Commit count: 264

cargo fmt