use log::{error, info, warn, LevelFilter}; use log4rs::{ append::console::ConsoleAppender, config::{Appender, Root}, encode::json::JsonEncoder, }; fn main() { let stdout: ConsoleAppender = ConsoleAppender::builder() .encoder(Box::new(JsonEncoder::new())) .build(); let log_config = log4rs::config::Config::builder() .appender(Appender::builder().build("stdout", Box::new(stdout))) .build(Root::builder().appender("stdout").build(LevelFilter::Info)) .unwrap(); log4rs::init_config(log_config).unwrap(); info!("Info log!"); warn!("Warn log with value {}", "test"); error!("ERROR!"); }