Logging API
On the Max platform, logging is performed using slf4j and platform application logs.
slf4j Logging
Operations have slf4j logging within the execution context.
Example
def logger = params["iop_logger"]
logger.debug("debug message")
logger.debug("debug message with {} and {}", "value1", "value2")
logger.error("error message")
logger.warn("warn message")
logger.info("info message")
Tail Log Operation
The Tail Log operation is available on development instances, and outputs the last lines of slf4j files:
https://<instance>/tail_log
By default, only the last 10 lines of the log file are output. To configure a different number of output lines, set the lines parameter to any value from 1 to 500. For example, to output the last 100 lines:
https://<instance>/tail_log?lines=100
|
To execute this operation, you must have the System Administrator or Developer role.
|
Platform Application Logging
In platform application logs, records with logged data are stored in the database. Application logs can have associated application log record type, which provide configuration parameters for the logger (for example, logging and retention policies). Max provides several log record types that you can use as a reference for future configurations.
User Activity Logging
The Default Application Log tracks user activity. Log messages are stored in application log records related to the user who executes the logic. Individual user activity is tracked in separate application log records to support visualization and troubleshooting. Additionally, application log records associated with individual users are preserved through multiple user sessions.
By default, the User application log is configured with the User application log type, whose logging level is set to ERROR. To change the logging level for a specific user to a lower level, for example, DEBUG, modify the Application Log Level field value in the relevant User Parameter record. This setting affects only log messages for the specified user, and you can configure different logging levels for other users.
To track specific activity for all operations including Event Handlers, access the logger by using the related operation parameters.
Example
To get the application log associated with the authenticated user:
def logger = parameters["iop_application_logger"]
try {
//the debug message will be logged only if the logging level is set accordingly on the authenticated user parameters (i.e. DEBUG)
logger.debug("start foo")
logger.debug("application log debug message")
logger.debug("application log debug message with {} and {}", "value1", "value2")
logger.error("application log error message")
logger.warn("application log warn message")
logger.info("application log info message")
logger.debug("end foo")
} catch(Exception e) {
//the error message will always be logged
logger.error("error on foo with exception:", e)
}