Logging efficiently in Rust

Logging is one of the most important parts of many applications and it's good to know that Rust has us covered in this regard. The default go-to crate should be the log crate, which provides us with useful macros for logging. Then, you can use the backend you want for the loggers, such as the env_logger crate or the log4rs crate.

The log crate gives us some macros, mainly trace!(), debug!()info!(),  warn!(), and error!(), in ascending order of relevance, which we can use to log events that happen in our application. It provides some more boilerplate, but that is basically it, you will now have to configure how those macros behave. For that, you have the actual implementations.

If you want an easy to use, common ...

Get Rust High Performance now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.