ABL Application Logging
- Last Updated: May 6, 2024
- 3 minute read
- OpenEdge
- Version 12.2
- Documentation
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
- An ABL interface called
ILogWriter. This interface provides methods likeError(),Info(),Debug(), etc, that you use to define log messages at various severity levels from within your ABL code. - An ABL class called
Loggerthat implements theILogWriterinterface. TheLoggeruses a configuration file named logging.config to process log events. - A factory class called
LoggerBuilderthat enables you to instantiate theLoggerfrom within your ABL code. - An ABL class called
LogEvent. ALogEventobject is created by theLoggerwhen anILogWriterinterface method (Error(),Info(), etc) is invoked. TheLogEventobject contains the log message, the timestamp of the event, etc. - Filter classes that format and write log events. These filters are used by
the
Loggerto process log events. The filters are categorized into two types: format filters and writer filters.Token_Formatfilter 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
LogLevelEnumthat defines log levels (OFF,FATAL,ERROR,WARN,INFO,DEBUG,TRACE). These log levels correspond to theILogWriterinterface'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
- Define log messages in your ABL classes.
- Write logging configurations in a logging.config file.
- 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.