mirror of
https://github.com/pykeio/ort
synced 2026-04-25 16:34:55 +02:00
58 lines
2.0 KiB
Plaintext
58 lines
2.0 KiB
Plaintext
---
|
|
title: 'Troubleshooting: Logging'
|
|
---
|
|
|
|
# Troubleshooting: Logging
|
|
|
|
import { Tabs, Steps } from 'nextra/components';
|
|
|
|
`ort` hooks into ONNX Runtime to route its logging messages through the [`tracing`](https://crates.io/crates/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`](https://crates.io/crates/tracing-subscriber). `tracing-subscriber`'s `fmt` subscriber logs readable (and quite pretty!) messages to the console. To set it up:
|
|
|
|
<Steps>
|
|
|
|
### Add `tracing-subscriber` to your dependencies
|
|
```toml Cargo.toml
|
|
[dependencies]
|
|
tracing-subscriber = { version = "0.3", features = [ "env-filter", "fmt" ] }
|
|
```
|
|
|
|
### Initialize the subscriber in the main function
|
|
```rust main.rs
|
|
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`](https://docs.rs/tracing-subscriber/latest/tracing_subscriber/filter/struct.EnvFilter.html) 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.)
|
|
<Tabs items={['Windows (PowerShell)', 'Windows (Command Prompt)', 'Linux', 'macOS']}>
|
|
<Tabs.Tab title="Windows (PowerShell)">
|
|
```powershell
|
|
$env:RUST_LOG = 'ort=debug';
|
|
cargo run
|
|
```
|
|
</Tabs.Tab>
|
|
<Tabs.Tab title="Windows (Command Prompt)">
|
|
```cmd
|
|
set RUST_LOG=ort=debug
|
|
cargo run
|
|
```
|
|
</Tabs.Tab>
|
|
<Tabs.Tab title="Linux">
|
|
```shell
|
|
RUST_LOG="ort=debug" cargo run
|
|
```
|
|
</Tabs.Tab>
|
|
<Tabs.Tab title="macOS">
|
|
```shell
|
|
RUST_LOG="ort=debug" cargo run
|
|
```
|
|
</Tabs.Tab>
|
|
</Tabs>
|
|
|
|
</Steps>
|