Crate slog_redis[][src]

This crate implements a slog drain that outputs JSON formatted logs to a Redis list

Useful for structured, 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!");

Structs

Builder

Builds the Redis logger.

Logger

A logger that sends JSON formatted logs to a list in a Redis instance. It uses this format

Enums

Error

Errors returned by the Builder and the Logger