How to print and view logs from Hyperledger Fabric chaincode

主宰稳场 提交于 2019-12-07 19:55:53

问题


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?


回答1:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!