1ac0ee271SDan Gohman# Logging in the `wasmtime` CLI 2ac0ee271SDan Gohman 3ac0ee271SDan GohmanWasmtime's libraries use Rust's [`log`] crate to log diagnostic 43c8bb264SPat Hickeyinformation, and the `wasmtime` CLI executable uses [`tracing-subscriber`] 53c8bb264SPat Hickeyfor displaying this information on the console. 6ac0ee271SDan Gohman 781375392SJonathan CoatesBasic logging is controlled by the `WASMTIME_LOG` environment variable. For example, 8ac0ee271SDan GohmanTo enable logging of WASI system calls, similar to the `strace` command on Linux, 93c8bb264SPat Hickeyset `WASMTIME_LOG=wasmtime_wasi=trace`. For more information on specifying 103c8bb264SPat Hickeyfilters, see [tracing-subscriber's EnvFilter docs]. 11ac0ee271SDan Gohman 12*92cfda1bSVictor Adossi```shell-session 133c8bb264SPat Hickey$ WASMTIME_LOG=wasmtime_wasi=trace wasmtime hello.wasm 14ac0ee271SDan Gohman[...] 1581375392SJonathan CoatesTRACE wiggle abi{module="wasi_snapshot_preview1" function="fd_write"} wasmtime_wasi::preview1::wasi_snapshot_preview1 > fd=Fd(1) iovs=*guest 0x14/1 16ac0ee271SDan GohmanHello, world! 1781375392SJonathan CoatesTRACE wiggle abi{module="wasi_snapshot_preview1" function="fd_write"}: wasmtime_wasi::preview1::wasi_snapshot_preview1: result=Ok(14) 1881375392SJonathan CoatesTRACE wiggle abi{module="wasi_snapshot_preview1" function="proc_exit"}: wasmtime_wasi::preview1::wasi_snapshot_preview1: rval=1 1981375392SJonathan CoatesTRACE wiggle abi{module="wasi_snapshot_preview1" function="proc_exit"}: wasmtime_wasi::preview1::wasi_snapshot_preview1: result=Exited with i32 exit status 1 20ac0ee271SDan Gohman``` 21ac0ee271SDan Gohman 22ac0ee271SDan GohmanWasmtime can also redirect the log messages into log files, with the 238995750aSAlex Crichton`-D log-to-files` option. It creates one file per thread within Wasmtime, with 24ac0ee271SDan Gohmanthe files named `wasmtime.dbg.*`. 25ac0ee271SDan Gohman 2641ff8e7bSSingleAccretionAdditional environment variables that work with `WASMTIME_LOG` (__not__ `-D log-to-files`): 2741ff8e7bSSingleAccretion - `WASMTIME_LOG_NO_CONTEXT`: if set to `1`, removes the time, level and target from output. 2841ff8e7bSSingleAccretion 29ac0ee271SDan Gohman[`log`]: https://crates.io/crates/log 303c8bb264SPat Hickey[`tracing-subscriber`]: https://crates.io/crates/tracing-subscriber 313c8bb264SPat Hickey[tracing-subscriber's EnvFilter docs]: https://docs.rs/tracing-subscriber/latest/tracing_subscriber/filter/struct.EnvFilter.html#directives 32