Logging and Debugging

It is handy to use logging because Logic Test Drive does not behave exactly the same way as when the logic runs in a "real" environment. Then the LOG file helps you find out what is going on.

Logging from Groovy

api.logInfo("Target Date", api.targetDate()) api.logWarn("A bigger problem", "something important")

Tracing (only under Logic Test)

api.trace("name", value1, value2)

Example

Given that you have a calculation logic with a Groovy element containing the following code:

api.trace("competitorName", null, competitorName) api.trace("competitorName", "", competitorName) api.trace("Current month - Last month", currentMonth, lastMonth)

When you run the calculation logic using the Test Logic (Debugger), then you get: 

Printing Information about Data Object

Groovy defines additional functions on objects:

  • dump()

  • inspect()

Both can be used to format nicely (and then display) what is in the object.

Accessing Log File

To see the log file for your partition:

  1. Go to Admin > View Logs.

  2. A new window with a "live" log opens, with the latest log record at the top. It reloads automatically every couple of seconds.

Setting up Logging

If a record does not show up in the log file, verify the following:

  1. Allow Groovy logging in General Settings in Configuration.
     Settings on this page do not apply immediately. Because of caching it can take up to 5 minutes.

  2. Ensure that your partition has the logging level set for SandboxAPI.

    1. Log in as the root.

    2. Go to System Admin > View Logs > Log Levels.

    3. Filter for "Sandbox" and check the level setting.

  3. If the logging still does not work, restart the pricefx-server.

Found an issue in documentation? Write to us.