5

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?

Chaitanya Reddy
  • 193
  • 1
  • 7
  • Did you check this? https://github.com/hyperledger/fabric/blob/master/docs/Setup/logging-control.md – gvlax Jan 24 '17 at 08:56
  • Yes. I referred this link and came up with the code I wrote. – Chaitanya Reddy Jan 24 '17 at 10:46
  • @cjcroix Sorry but I don't get what you mean by dev or net. I followed the instructions in this tutorial. Please have a look - [link](https://www.ibm.com/developerworks/community/blogs/8d277a63-4204-4fd3-8cb8-b7cb222cd522/entry/Steps_to_setup_Blockchain_Hyperledger_Fabric_0_6_development_environment_on_Ubuntu?lang=en) – Chaitanya Reddy Jan 27 '17 at 05:38
  • figured it out..thanks for the help! – Chaitanya Reddy Feb 07 '17 at 06:10
  • For me, I use "docker attach " in case that I use fmt.Println instead of the logger.Info in my chaincode. – Dara Tith Mar 31 '20 at 07:51

1 Answers1

6

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)>

Clyde D'Cruz
  • 1,915
  • 1
  • 14
  • 36