Unable to print to logs in Hyperledger chaincode

独自空忆成欢 提交于 2019-12-13 15:21:59

问题


Why am I not able to see output of any of the "fmt.Println" or "fmt.Printf" statements specified in the chaincode in the logs even when the logging level is set to "DEBUG"?

I am using pre-built docker images to start a hyperledger node in Ubuntu.


回答1:


Most likely that is happening because you are trying to find your messages in a log stream which is generated by peer server. But chaincode is executed in independent docker container and has it's own log stream.

In order to get an access to the chaincode's logs, on the same server where peer process is started, right after chaincode is deployed:

  1. Tun command docker ps. The output should looks like:

    77636df123e3        dev-jdoe-1edd7(...YOUR CHAINCODE  ID)
    
  2. Then attach to docker container where your chaincode is exectued using docker attach 77636df123e3

  3. Execute any of your chaincode's methods and check if log messages appears in this stream




回答2:


some things like this:

docker logs dev-peer1.org2.example.com-mycc-1.0


来源:https://stackoverflow.com/questions/41095712/unable-to-print-to-logs-in-hyperledger-chaincode

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