seleniumbase-rs uses the tracing ecosystem for structured logging. Both the
sbrs CLI and the sbrs-mcp server initialize a default
tracing_subscriber::fmt() subscriber on startup. This page explains how to
control verbosity, configure runtime settings through the environment, and use
tracing in your own tests.
What you will learn
- How to set log levels with
RUST_LOG. - How
SB_*environment variables configure runtime behavior. - How spans and structured errors help diagnose failures.
- How to use tracing in your own async code.
Log levels#
Set the RUST_LOG environment variable to control verbosity:
RUST_LOG follows the standard env_logger/tracing-subscriber syntax:
Runtime configuration (SB_* environment variables)#
Following Twelve-Factor III (config in the environment),
sbrs and the library read runtime settings from SB_* variables:
Directory for patched Chrome/Chromedriver copies.
Default: "platform cache dir"
The tracing filter (debug, seleniumbase_rs=debug,info). Unset, blank or invalid, sbrs and sbrs-mcp use RUST_LOG, then info.
Parsed into RuntimeConfig::chromedriver_port; nothing in the crate reads it yet.
Default: "0"
Parsed into RuntimeConfig::implicit_wait; nothing in the crate reads it yet.
Default: "30"
One bad value does not undo the others: with SB_SHUTDOWN_TIMEOUT_SECS=soon
sbrs still honours SB_LOG_LEVEL=debug, uses the default timeout and logs a
warning that names the variable. A program that builds the configuration itself
can do the same with RuntimeConfig::from_env_lenient(), which returns the
configuration and the list of problems.
Spans in the library#
Key BaseCase and BrowserSession methods are instrumented with tracing
spans so you can see where time is spent:
BaseCase::newBaseCase::with_sessionBaseCase::open,click,type_text,quitBrowserSession::connect
Example output:
Using tracing in your own tests#
Tauri multi-profile example#
The Tauri app also initializes tracing_subscriber in src-tauri/src/lib.rs.
Its REST API logs each endpoint call so you can correlate UI actions with local
HTTP requests.
Error diagnostics#
Errors are emitted as structured tracing::error! events. Each event includes:
Stable tag such as element_not_found or browser_launch.
Whether the failure is retryable.
A short remediation suggestion.
Example output:
You can also log errors manually:
Enable the full-tracing feature for additional timing histograms and Actix
actor instrumentation.
Watching async tasks with tokio-console#
Feature: tokio-consoleWhen something hangs, tokio-console shows every async task live: which ones are waiting, for how long, and on what.
Run with the instrumentation
Build with the tokio-console feature and tokio’s unstable instrumentation (both are
for debugging only and make the program bigger):
Start the console
In another terminal:
It connects to 127.0.0.1:6669. Your own program gets the same when it calls
seleniumbase_rs::tracing_util::init_tracing() with the feature on.
Troubleshooting#
No log output
Likely cause: Subscriber not initialized.
Fix: Run through sbrs, sbrs-mcp, or call tracing_subscriber::fmt::init() in your main().
Too much noise from dependencies
Likely cause: RUST_LOG=debug includes all crates.
Fix: Scope to seleniumbase_rs=debug.
JSON format not working
Likely cause: SB_LOG_FORMAT=json unsupported by default subscriber.
Fix: Use a custom subscriber or enable the full-tracing feature.
Shutdown timeout errors
Likely cause: SB_SHUTDOWN_TIMEOUT_SECS too low.
Fix: Increase it for slow CI agents.