The OpenEdge Logger framework provides ABL classes and interfaces that enable you to implement logging in your ABL application in a configurable way. Using this framework, you define custom log messages at various severity levels in your ABL application code. When the code runs, the framework produces log events containing the defined log messages. The log messages are then formatted and written to log files based on logging configurations defined in a configuration file.
Note: The log file path is also specified through a filter in the configuration file.

Because it uses configuration files, the Logger framework enables you to control the logging behavior (what gets written and where) without having to change your ABL application code.

The Logger framework is modeled on the SLF4J pattern.

Key components

The OpenEdge Logger framework provides the following components:
  • An ABL interface called ILogWriter. This interface provides methods like Error(), Info(), Debug(), etc, that you use to define log messages at various severity levels from within your ABL code.
  • An ABL class called Logger that implements the ILogWriter interface. The Logger uses a configuration file named logging.config to process log events.
  • A factory class called LoggerBuilder that enables you to instantiate the Logger from within your ABL code.
  • An ABL class called LogEvent. A LogEvent object is created by the Logger when an ILogWriter interface method (Error(), Info(), etc) is invoked. The LogEvent object contains the log message, the timestamp of the event, etc.
  • Filter classes that format and write log events. These filters are used by the Logger to process log events. The filters are categorized into two types: format filters and writer filters. Token_Format filter is a type of the format filter that allows you to use tokens in the log messages. For more information, see Log filters and Logging tokens.
  • Extension points that enable you to write custom filters.
  • An enumerated type named LogLevelEnum that defines log levels (OFF, FATAL, ERROR, WARN, INFO, DEBUG, TRACE). These log levels correspond to the ILogWriter interface's methods.

How it works

You instantiate the Logger through the LoggerBuilder and then use the ILogWriter interface's methods to define log messages at various severity levels in your ABL class. When your ABL class executes, a LogEvent object is produced for each log message defined in your code. These log events are processed by the Logger based on configurations defined in a logging.config file.

You must create the logging.config file manually and write the configurations in JSON. Each configuration has properties such as a name to identify itself, the log level (INFO, DEBUG, TRACE, etc), and references to filters that format and write log events.

By separating the configuration of logging from its implementation, you get the benefit of being able to modify logging behavior without having to modify ABL code. At runtime, an administrator can simply update configurations in the logging.config file to change log levels, specify log message formats, etc.

How to use it

To implement basic logging behavior, you need to perform the following tasks:
  1. Define log messages in your ABL classes.
  2. Write logging configurations in a logging.config file.
In addition, you can do the following:
  • Set up a logger hierarchy, where a logging configuration applies to groups of ABL classes.
  • Create a custom filter, if the built-in filters do not meet your requirements.