Skip to content
Discussions/App Development/DAML Template - Trace/Debug/LoggingForum ↗

DAML Template - Trace/Debug/Logging

App Development7 posts237 views4 likesLast activity Jul 2022
PR
prajwalhegde3OP
Jul 2022

Hi Everyone!!

Is there a way to log values from the template/choice into a log file.

choice Iou_Split : (IouCid, IouCid)
        with
        splitAmount: Decimal
      controller owner
      do
        let restAmount = amount - splitAmount
        splitCid <- create this with amount = splitAmount
        restCid <- create this with amount = restAmount
        return (splitCid, restCid)

Can anyone help, how could I log “splitCid” value into log for better understanding.

Thanks!

NE
nemanja
Jul 2022

Hi @prajwalhegde3 :wave:

I think you can use debug to print the value.

PR
prajwalhegde3
Jul 2022

@nemanja : Thanks for the response.

But still kind of confused. I have added the debug statements in my choice and have checked the canton and sandbox logs, can’t find what I’m looking for.

May be an example and advice which log file to refer would be helpful.

Thank you!

NE
nemanja
Jul 2022

Hi @prajwalhegde3 :wave:

How are you executing the choice? Are you using Daml script or REPL to test the workflow?

PR
prajwalhegde3
Jul 2022

Hi @nemanja

For now executing the choice through the Navigator app.

NE
nemanja
Jul 2022

So you need to start the sandbox with debugging enabled

When I run the sandbox like this:

daml start --sandbox-option --debug I get the output in the default log location ( log/canton.log)

Note that if there are errors in your code and the execution doesn’t reach your debug statement you won’t see the output.

PR
prajwalhegde3
Jul 2022

Thank you @nemanja

← Back to Discussions