Testing Dynamic Logic Using Logs
Here are the steps to test dynamic logic using logs:
Prerequisites
-
You need to add the log statements to the database for using the API that fetches log statements. You need to configure the following application property:
ohi.logging.target = database
Since the property is protected, you need to configure the property in the application properties file. You cannot set the property through the generic or properties API.
-
You must have the log back configuration for log Appenders. Refer to Logging to a Central Database for more information.
Step 1: Add Logger
POST {apiurl}/generic/loggers { "logger": "ohi.dynamiclogic", "logLevel": "DEBUG", "duration": "600" }
The duration of the log to remain active is in minutes. |
Step 2: Add Debug Statements
In this step, you add the debug statements to your dynamic logic. For example:
log.debug("start") name = newPerson.firstName log.debug("name: ${name}") log.debug("stop")
When adding variables in a debug statement, use a dollar sign ($) and place the variable between curly braces. It is mandatory to use both dollar sign and curly braces as using either leads to undesirable results. |