Skip to main content
Version: 2.0.x

Debug Log

Statement Logging

SeaORM logs debug messages via the tracing crate.

You can enable SeaORM's logging with the debug-print feature flag:

[dependencies.sea-orm]
version = "2.0.0-rc"
features = ["debug-print"]

You need to setup tracing-subscriber to capture and view the debug log. See the snippet below and a complete example here.

pub async fn main() {
tracing_subscriber::fmt()
.with_max_level(tracing::Level::DEBUG)
.with_test_writer()
.init();

// ...
}

SeaORM's debug print injects parameters into the SQL string, which makes it easier to read. Instead of seeing:

SELECT "cake"."name" FROM "cake" WHERE "cake"."id" = $1

you will see:

SELECT "cake"."name" FROM "cake" WHERE "cake"."id" = 101

SQLx Logging

SQLx also logs by default. If you turned on SeaORM's debug-print, you can disable SQLx's log by passing ConnectOptions to connect().

let mut opt = ConnectOptions::new("protocol://username:password@host/database".to_owned());
opt.sqlx_logging(false); // disable SQLx logging

let db = Database::connect(opt).await?;