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?
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)>
来源:https://stackoverflow.com/questions/41823340/how-to-print-and-view-logs-from-hyperledger-fabric-chaincode