Chaitanya Reddy
Chaitanya Reddy

Reputation: 313

How to print and view logs from Hyperledger Fabric chaincode

I want to see logs while calling functions in my chaincode, for debugging purposes. I tried something like this:

var logger = shim.NewLogger("chaincode_example02")
logger.Info("get_caller_data called");

I've viewed logs of the peer running the chaincode, but I couldn't find the above log. What am I doing wrong?

Upvotes: 6

Views: 9586

Answers (1)

Clyde D'Cruz
Clyde D'Cruz

Reputation: 2065

If you startup your chaincode in dev mode using a command like ./chaincode_example02, then the log statements should be visible in the console where that same process is started.

If you deploy the chaincode in net mode then each peer starts up a docker container that is named something like <networkId>-<peer enroll id>-<chaincode Id> .You can view all the docker containers started up on a peer by using the command docker ps, and view the content of a log by using the command docker logs <container id (get this from the previous command)>

Upvotes: 7

Related Questions