ort
hooks into ONNX Runtime to route its logging messages through the tracing
crate. These logging messages can often provide more helpful information about specific failure modes than ort
’s error messages alone.
To enable logging for ort
, you need to set up a tracing
subscriber in your application, such as tracing-subscriber
. tracing-subscriber
’s fmt
subscriber logs readable (and quite pretty!) messages to the console. To set it up:
Add tracing-subscriber
to your dependencies
[dependencies]
tracing-subscriber = { version = "0.3", features = [ "env-filter", "fmt" ] }
Initialize the subscriber in the main function
fn main() {
tracing_subscriber::fmt::init();
}
Show debug messages from ort
The environment variable RUST_LOG
configures filters for crates that use tracing
; see tracing_subcriber::EnvFilter
for more information.
Set RUST_LOG
to ort=debug
to see all debug messages from ort
. (You can also set it to trace
for more verbosity, or info
, warn
, or error
for less.)
$env:RUST_LOG = 'ort=debug';
cargo run