Define log messages in your ABL class
- Last Updated: June 27, 2025
- 3 minute read
- OpenEdge
- Version 12.2
- Documentation
OpenEdge.Logging package in the
OpenEdge.Core.pl or OpenEdge.Core.apl library, which
gets added to an ABL application's PROPATH by default.OpenEdge.Logging
classes and interfaces, see the OpenEdge.Logging package in the OpenEdge ABL API Reference.ILogWriter interface and the LoggerBuilder class. Use them as follows:- (Optional) Import the following packages in your ABL class:
using OpenEdge.Logging.ILogWriter. using OpenEdge.Logging.LoggerBuilder. - Define a variable for the
ILogWriterinterface:define variable logger as ILogWriter no-undo. - Use the LoggerBuilder's
GetLogger()factory method to instantiate theLoggerby passing the name of a logging configuration:logger = LoggerBuilder:GetLogger("my.ABL.Class").The name that you specify here (my.ABL.Classin this example) should match the name of a logging configuration in the logging.config file. This instructs theLoggerBuilderto use that configuration to when instantiating theLogger. It is a good practice to use the fully qualified name of your ABL class as the logging configuration name (in thelogging.configfile and also when instantiating the Logger). This makes it easy for administrators to know which configuration to modify to control logging for an ABL class. In addition, this may enable the configuration of a logger hierarchy in the logging.config file. To learn more, see Set up a logger hierarchy.Note: If theLoggerBuilderdoes not find a matching logging configuration in the logging.config file, it either instantiates aVOIDlogger (which acts as a sink for log events), or writes events to theLog-Manager, depending on the client type. - Write log messages at different severity levels using the following
interface methods:
logger:Fatal() logger:Error() logger:Warn() logger:Info() logger:Debug() logger:Trace()These methods correspond to log levels defined in the
LogLevelEnumenumerated type. See Log levels for guidelines on how to use these log levels. When the ABL code runs, aLogEventobject is created for each of these methods. They are processed based on the log level set in the logging configuration. To know more, see Write logging configurations in a logging.config file.Each of the interface methods has two signature styles—string and object. They are described below.
String style
The string style signature takes the following parameters:
| Parameter | Description | Required? |
|---|---|---|
CHARACTER MessageGroup |
A name of a message group. | No |
CHARACTER Message |
The log message that needs to be written. | Yes |
Progress.Lang.Error
ErrorObject |
An error object. | No |
Examples:
logger:Info("Customer record found").
logger:Warn("CUSTOMER-MESSAGES", "Customer record missing").
logger:Error("An exception occurred", ErrorObject)
Object style
The Logger wraps
the string style message in a LogMessage object
when it produces a log event, but you can create your own LogMessage object as well. The main reason for doing this is if you
want to pass arguments in the message that get their values from elements in an
array. To specify a LogMessage object, you need to
use the object style signature, which takes the following parameters:
| Parameter | Description | Required? |
|---|---|---|
OpenEdge.Logging.LogMessage. LogMessageObject |
A LogMessage object that contains a group name,
message, and an array of character arguments. |
Yes |
Progress.Lang.Error
ErrorObject |
An error object. | No |
How to create a LogMessage object
Create a LogMessage object using its class constructor, which
accepts the following parameters:
| Parameter | Description |
|---|---|
CHARACTER GroupName |
A name of a message group. |
CHARACTER BaseText |
A string that can contain arguments denoted
by &1, &2, &3.. etc, whose values are retrieved from
elements in an array. Up to 9 arguments can be
specified. |
CHARACTER EXTENT
ArgumentArray |
A character array. The value of elements in
the array will substitute the arguments in the BaseText parameter. You can either
specify an array name or specify a comma-separated list of
strings. |
Example:
using OpenEdge.Logging.LogMessage.
...
...
define variable cArgs as character extent 3.
...
...
cArgs[1] = "3".
cArgs[2] = "Hoops".
cArgs[3] = "Atlanta".
...
...
logger:Info(new LogMessage("CUSTOMER-MESSAGES", "Customer found. ID: &1. Name: &2. City: &3.", cArgs)).
logger:Info(new LogMessage("CUSTOMER-MESSAGES", "Customer found. ID: &1. Name: &2.
City: &3.", "3", "Hoops", "Atlanta")).
"Customer found. ID: 3. Name: Hoops. City: Atlanta."
ABL_SUBSTITUTE_FORMAT filter in the
logging configuration. See Log filters to learn
more.