Log Utilities
Intended Audience:
Technical User
Author:
Kirill Gaiduk
Changed on:
10 July 2025
Overview
The`LogUtils` class in the `util-core` bundle provides structured logging helpers that remove boilerplate code when using logging actions within your rules. These utilities make it easy to record key actions, errors, and checkpoints to the event log for debugging and auditing purposes.Key points
- Standardized Logging: The utilities provide a standard, structured format for log messages, making the event log easier to read and search.
- Automatic Titling: The log entry's title is automatically generated from the rule's class name, ensuring consistency and saving you from writing boilerplate code.
- Simple Checkpoints:
`logOnce`is an easy way to record a specific outcome or checkpoint in your rule's execution with a formatted message. - Collections:
`logAttributeCollection`is a convenient helper for logging a list of attributes.
Key Concepts
The logging utilities are wrappers around the standard`context.action().log()` method. They provide two main benefits:- Automatic Titling: The title of the log entry is automatically generated from the
`@RuleInfo`name of the rule class you provide. This creates consistent`LogEvents`which can be searched and filtered through the Event API. - Structured Formatting: The methods provide a clear structure for the log's title and subtitle (using
`String.format()`), making the event log easier to read and query.
Core Methods
`logOnce`
This method logs a single, formatted message to the event log. It is ideal for recording a specific, meaningful outcome or checkpoint in your rule's execution.The log title is automatically set to "Rule logs for rule YourRuleName". The subtitle is generated from your format string and arguments.`logAttributeCollection`
This method is used to log a `List` of `Attribute` objects. The log title is the same as `logOnce`, and the subtitle is formatted as "LogCollection:[size]", where size is the number of attributes in the list. 