Star us on GitHub
Star
Menu

Logging without a Rust framework

Learn how to set up highlight.io Rust log ingestion.
1
Set up your highlight.io SDK.

First, make sure you've followed the backend getting started guide.

2
Install the log crate.

Highlight works with the log crate to make logging easier.

[dependencies] log = "0.4"
Copy
3
Call the logging facades.

Highlight::init automatically installs a logging backend, so you can call any of the log crate's macros to emit logs. NOTE: env_logger only logs errors on the console out by default, so to see your logs, run your project with the RUST_LOG=<crate name> environment variable, or RUST_LOG=trace to see everything.

use log::{trace, debug, info, warn, error}; // ... trace!("This is a trace! log. {:?}", "hi!"); debug!("This is a debug! log. {}", 3 * 3); info!("This is an info! log. {}", 2 + 2); warn!("This is a warn! log."); error!("This is an error! log.");
Copy
4
Verify your backend logs are being recorded.

Visit the highlight logs portal and check that backend logs are coming in.