Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

nikania
nikania

Posted on

     

Using log in Substrate

How to log in substrate pallets and how to see logs when running node (can be useful to see existing logs in polkadot when debugging).

Import log crate in Cargo.toml of pallets/template

[dependencies]log="0.4"
Enter fullscreen modeExit fullscreen mode

Add some logging to extrinsicdo_something in pallet-template (gibberish in my case)

log::trace!(target:"lalala","do_something is working!");log::trace!(target:"ononono","do_something is working!");log::trace!(target:"test::werr","do_something is working!");...log::trace!(target:"lalala","do_something is done!");log::trace!(target:"ononono","do_something is done!");log::trace!(target:"test::werr","do_something is done!");
Enter fullscreen modeExit fullscreen mode

Build node, and run with log filtering (filters onlytarget: "lalala" trace logs):

./target/release/node-template--dev--tmp--loglalala=trace
Enter fullscreen modeExit fullscreen mode

when execute extrinsics, trace log is in output:

Image description

different filtering (notice thattarget: "test::werr" can be filtered like thattest=trace)

./target/release/node-template--dev--tmp--loglalala=traceononono=tracetest=trace
Enter fullscreen modeExit fullscreen mode

--different output

Image description

For example to trace xcm messages in parachains/relay chain filter can be used:--log xcm=trace

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

  • Joined

More fromnikania

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp