无法打印到Hyperledger链码中的日志 [英] Unable to print to logs in Hyperledger chaincode
问题描述
为什么即使将日志记录级别设置为"DEBUG",也无法在日志中看到链代码中指定的任何"fmt.Println"或"fmt.Printf"语句的输出?
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"?
我正在使用预构建的Docker映像在Ubuntu中启动Hyperledger节点.
I am using pre-built docker images to start a hyperledger node in Ubuntu.
推荐答案
最有可能发生的原因是,您试图在对等服务器生成的日志流中查找消息.但是chaincode是在独立的docker容器中执行的,并且具有自己的日志流.
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.
为了访问链代码的日志,请在部署链代码之后立即在启动peer
进程的同一台服务器上:
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:
-
调节命令
docker ps
.输出应如下所示:
77636df123e3 dev-jdoe-1edd7(...YOUR CHAINCODE ID)
然后附加到使用以下代码执行链式代码的docker容器
docker attach 77636df123e3
Then attach to docker container where your chaincode is exectued using
docker attach 77636df123e3
执行任何链码方法,并检查日志消息是否出现在此流中
Execute any of your chaincode's methods and check if log messages appears in this stream
这篇关于无法打印到Hyperledger链码中的日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!