Hitarshi Buch
Hitarshi Buch

Reputation: 115

Unable to print to logs in Hyperledger chaincode

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.

Upvotes: 3

Views: 1600

Answers (2)

Strew Stanza
Strew Stanza

Reputation: 11

some things like this:

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

Upvotes: 1

Sergey Balashevich
Sergey Balashevich

Reputation: 2101

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

Upvotes: 8

Related Questions