What is the best practice for logging in pallets? Is there any overhead leaving them in at a debug/trace level? Or should we never use them outside of development?



2 Answers 2


Generally, it is recommended to avoid logging inside the runtime This can lead to some issues, a few I can think of are:

  • Increases the size of the Wasm binary that your chain will be running.
  • Ideally, you want to keep your extrinsics as concise as possible. Adding extra execution steps may result in an increase in weight, which could lead to higher fees for executing the call.
  • Depending on the wasm compiler used to create the binary, logging outside of a Debug environment can cause some problems. This is because WebAssembly might not have access to some system-level calls needed to print data.

Refer to the Debug Section - Substrate docs for more info.

In a production environment, it is recommended to use Errors and Events to provide information on the internal behavior of the call within a pallet.

Here’s an answer to a different question that could also help.


You abosultely can log in runtime.

No need to worry about the WASM. Just use it like you are developing a Rust program.

You can enable this feature while building the runtime release. It will disable the log in the WASM.

You can still see the log by not enable this feature in the binary build.


  • When logs are not enabled (for mainnet/production), is there zero overhead or does it leave some code in? Apr 20, 2023 at 13:16
  • No any log code gets injected.
    – AurevoirXavier
    Apr 20, 2023 at 13:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.