The OpenEdge Logger framework comprises a set of ABL classes and interfaces that are provided in the OpenEdge.Logging package in the OpenEdge.Core.pl or OpenEdge.Core.apl library, which gets added to an ABL application's PROPATH by default.
Note: The .apl version of the listed library is a signed archive library. You should choose the appropriate type (.pl or .apl) based on your security needs. For more information, see Manage Libraries in Manage ABL Applications.
For detail on the OpenEdge.Logging classes and interfaces, see the OpenEdge.Logging package in the OpenEdge ABL API Reference.
To define log messages, you mainly need the ILogWriter interface and the LoggerBuilder class. Use them as follows:
  1. (Optional) Import the following packages in your ABL class:
    using OpenEdge.Logging.ILogWriter.
    using OpenEdge.Logging.LoggerBuilder.
  2. Define a variable for the ILogWriter interface:
    define variable logger as ILogWriter no-undo.
  3. Use the LoggerBuilder's GetLogger() factory method to instantiate the Logger by passing the name of a logging configuration:
    logger = LoggerBuilder:GetLogger("my.ABL.Class").
    The name that you specify here (my.ABL.Class in this example) should match the name of a logging configuration in the logging.config file. This instructs the LoggerBuilder to use that configuration to when instantiating the Logger. It is a good practice to use the fully qualified name of your ABL class as the logging configuration name (in the logging.config file 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 the LoggerBuilder does not find a matching logging configuration in the logging.config file, it either instantiates a VOID logger (which acts as a sink for log events), or writes events to the Log-Manager, depending on the client type.
  4. 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 LogLevelEnum enumerated type. See Log levels for guidelines on how to use these log levels. When the ABL code runs, a LogEvent object 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)).
Alternatively, you can supply the substitution values as follows:
logger:Info(new LogMessage("CUSTOMER-MESSAGES", "Customer found. ID: &1. Name: &2. 
City: &3.", "3", "Hoops", "Atlanta")).
This will produce an output log message that looks like this:
"Customer found. ID: 3. Name: Hoops. City: Atlanta."
Note: For this to work, you need to use an ABL_SUBSTITUTE_FORMAT filter in the logging configuration. See Log filters to learn more.