Markdown Files
Void Logger
A logging backend for the standard log crate facade that formats and prints log lines to the console (stdout/stderr) while simultaneously queuing and sending them in compressed batches to a Void ingestion server.
Integration Tutorial: void-logger
This guide describes how to integrate and initialize the void-logger in your Rust applications so that you can log using the standard log facade macros (like info!, warn!, error!, etc.). The logger will automatically format and print your log messages to the console (stdout/stderr) while simultaneously queuing and sending them in compressed batches to your Void ingestion server.
1. Add Dependencies
Add the standard log facade and void-logger to your project's Cargo.toml dependencies:
[dependencies]
log = "0.4"
void-logger = "0.1.0"
2. Initialize the Logger
Initialize the logger at the entry point of your application (usually at the start of fn main()). You can configure the ingestion URL, service name, standard max log level, compression, and console output.
use std::time::Duration;
use log::{info, warn, error};
use void_logger::{VoidLoggerBuilder, ConsoleOutput, ContentEncoding, ContentType};
fn main() {
// Build and initialize the global logger
VoidLoggerBuilder::new("http://127.0.0.1:9180/ingest")
.service_name("my-awesome-service")
.max_level(log::LevelFilter::Info)
.batch_size(50) // Send in batches of 50
.batch_timeout(Duration::from_secs(2)) // Or at least every 2 seconds
.content_encoding(ContentEncoding::Gzip) // Enable compression
.content_type(ContentType::Json) // Ingestion content type
.console_output(ConsoleOutput::Split) // Print logs to console (split stdout/stderr)
.init()
.expect("Failed to initialize VoidLogger");
info!("Application successfully initialized with Void Logger!");
// Your application code here...
}
3. Console Output Configuration
The console_output setting controls where the logger prints messages to the console:
ConsoleOutput::Split(Default): Prints warnings and errors to standard error (stderr), and info/debug/trace logs to standard output (stdout). This is recommended for most services, especially in containerized or server environments.ConsoleOutput::Stderr: Prints all log messages formatted nicely to standard error.ConsoleOutput::Stdout: Prints all log messages formatted nicely to standard output.ConsoleOutput::None: Disables console printing entirely. Only sends logs to the Void server.
Example log output format:
[2026-06-04T12:00:00.123Z] INFO [my_awesome_service] Application successfully initialized with Void Logger!