Is there is a way to fetch canister logs using ic-cdk
or using agent-rs
. Also is it possible right now for a canister to fetch its own logs?
@maksym Could you kindly assist me with this matter?
hi @gravity_vi.
Is there is a way to fetch canister logs using
ic-cdk
or usingagent-rs
.
currently one can fetch logs using DFX, see examples for Rust and Motoko.
agent-rs
should work fine, because DFX is using it to fetch logs, see here.
agent-js
might not yet be up-to-date in regards to reading/writing log_visibility
but it is going to be fixed soon.
Also is it possible right now for a canister to fetch its own logs?
no, canisters can not fetch logs as per specification:
IC method fetch_canister_logs
This method can only be called by external users via non-replicated calls, i.e., it cannot be called by canisters, as replicated calls, and from composite query calls.
Thank you @maksym. I have few more questions:
-
How do we upgrade the current canisters log_visibility as
ic_cdk
latest version canister settings does not contain any option for the log_visibility? -
Our canisters have been structured such that in a subnet all the individual canisters are controlled by one canister (user_index). So that user_index is the controller of the all the existing canisters and responsible for spawning new individual canisters. Assuming there is no way for user_index to fetch logs from all the individual canisters, how can I ensure that exising canisters and as well as new canisters are maked with log_visibility as public?
For the first question: You can pin the ic_cdk
version to the git rev of this PR
After Severin’s PR is merged and released it will be possible to update canister settings and change log_visibility.
Additionally (in a more distant future) we are considering adding allowed list to log_visibility so that it’s not fully public and not strictly controllers.
Something what we should also add to our IC4J Java Agent.