Great question!
To make trace statements visible you need to set the log level of daml.tracelog
to DEBUG
. There are two ways to to this:
Show all debug logs
You can run daml sandbox --log-level=DEBUG
and it will show you all debug logs which includes the daml.tracelog
logs. However, it will show you much much more than that so this is probably not what you want.
Use a custom logback.xml
Instead of showing all debug statements you can select daml.tracelog
individually. This requires that you write a custom logback configuration file. You can find the default logback config used by daml sandbox
at $HOME/.daml/sdk/$YOUR_SDK_VERSION/daml-sdk/sandbox-logback.xml
. Start by copying that to your project directory as logback.xml
. Next modify it to change the end such that it looks like this:
<logger name="daml.tracelog" level="DEBUG" />
<root level="INFO">
<appender-ref ref="STDOUT"/>
<appender-ref ref="ASYNC"/>
</root>
</configuration>
Now you have to get sandbox to pick up this modified file. There are two options for this:
First you can set the _JAVA_OPTIONS
environment variable via
export _JAVA_OPTIONS="-Dlogback.configurationFile=./logback.xml"
That will then be picked up by all JVM processes. Note that it is important to use _JAVA_OPTIONS
and not JAVA_TOOL_OPTIONS
. The former takes precedence over CLI arguments while the latter doesn’t so you cannot use it to override the logback config passed by the assistant. It also seems to be important to use ./logback.xml
or an absolute path instead of logback.xml
.
The other option is to sidestep the assistant completely. Note that this relies on details of the SDK tarball which are not guaranteed to be stable across versions. The JAR invoked by daml sandbox
is located at ~/.daml/sdk/$YOUR_SDK_VERSION/daml-sdk/daml-sdk.jar
. You can invoke that directly via java -jar
. Since there is a single JAR for the whole SDK you have to pass sandbox
as the first argument. Putting things together, you can launch sandbox with a given logback config as follows:
java -Dlogback.configurationFile=./logback.xml -jar ~/.daml/sdk/1.1.1/daml-sdk/daml-sdk.jar sandbox .daml/dist/foobar-0.0.1.dar
Sidenote
The log statement will be printed whenever it is evaluated. In thew new sandbox, this seems to happen twice (presumably once for validation) so you see the log statement twice as well. In Sandbox classic, it is only printed once.