Let’s work together
Want to discuss potential opportunities? Pick the most suitable way to contact us.
Book a call+370 5 2 780 400
info@ba.lt
When developing applications in Progress OpenEdge, logging is essential for tracking runtime behavior, debugging, and generating reports. The LOG-MANAGER system handle and the OpenEdge Logger Framework are two powerful tools for managing logging in OpenEdge applications.
This blog explores the methods of implementing logging in OpenEdge, focusing on both the LOG-MANAGER system handle and the OpenEdge Logger Framework, comparing their features and providing practical examples of usage.
The LOG-MANAGER system handles OpenEdge controls logging settings for both the OpenEdge client and the DataServer client contexts. It offers flexibility in controlling the type and amount of logged information using a combination of log entry types and logging levels. It allows developers to programmatically control logging while executing an ABL (Advanced Business Language) program or components within the Progress Application Server (PAS) for OpenEdge.
LOG-MANAGER:LOGGING-LEVEL = 3.
LOG-MANAGER:LOG-ENTRY-TYPES = "4GLMessages:2,4GLTrace:3,4GLTrans:2".
To illustrate the practical application of LOG-MANAGER, let us consider a basic implementation that sets up logging parameters, writes various messages to the log, and then closes the log file.
LOG-MANAGER:LOGFILE-NAME = "managerLogs.log".
LOG-MANAGER:LOGGING-LEVEL = 3.
LOG-MANAGER:LOG-ENTRY-TYPES = "4GLMessages,4GLTrace,4GLTrans".
LOG-MANAGER:WRITE-MESSAGE("Application logging initialized with file: " + LOG-MANAGER:LOGFILE-NAME).
LOG-MANAGER:WRITE-MESSAGE(LOG-MANAGER:ENTRY-TYPES-LIST).
LOG-MANAGER:WRITE-MESSAGE(STRING(LOG-MANAGER:LOG-THRESHOLD), "CUSTOM").
LOG-MANAGER:WRITE-MESSAGE(STRING(LOG-MANAGER:NUM-LOG-FILES), "CUSTOM-2").
LOG-MANAGER:CLOSE-LOG().
Output written to managerLogs.log
[24/12/06@13:19:55.080+0100] P-010008 T-014460 1 4GL -- Logging level set to = 2
[24/12/06@13:19:55.082+0100] P-010008 T-014460 1 4GL -- No entry types are activated
[24/12/06@13:19:55.082+0100] P-010008 T-014460 1 4GL -- Logging level set to = 3
[24/12/06@13:19:55.082+0100] P-010008 T-014460 1 4GL -- Log entry types activated: 4GLMessages,4GLTrace,4GLTrans
[24/12/06@13:19:55.082+0100] P-010008 T-014460 1 4GL APPL Application logging initialized with file: managerLogs.log
[24/12/06@13:19:55.082+0100] P-010008 T-014460 1 4GL APPL 4GLMessages,4GLTrace,4GLTrans,Actional,ASK,DB.Connects,DB.Encryption,DS.Cursor,DS.QryInfo,DS.Performance,DynObjects.Class,DynObjects.DB,DynObjects.Other,DynObjects.UI,DynObjects.XML,FileID,IgnoredOps,MSASAdmin,MSASCRTInterposed,MSASSessions,MSASSignals,MSASSockets,MSASWebSocket,MSASDebugger,ProEvents.UI.Char,ProEvents.UI.Command,ProEvents.Other,QryInfo,SAX,Temp-Tables,TTStats,WSO
[24/12/06@13:19:55.082+0100] P-010008 T-014460 1 4GL CUSTOM 0
[24/12/06@13:19:55.082+0100] P-010008 T-014460 1 4GL CUSTOM-2 3
[24/12/06@13:19:55.082+0100] P-010008 T-014460 1 4GL ---------- Log file closed at user's request
The LOG-MANAGER system handle is effective for standard logging and reporting runtime activities. It is useful for basic logging, tracing, and debugging but lacks the flexibility for more advanced logging configurations.
The OpenEdge Logger Framework provides a more flexible and configurable solution for logging in Progress OpenEdge applications. It enables developers to define custom log messages at various severity levels, format them, and store them in log files based on configuration settings. This framework allows logging behaviour to be controlled without modifying the application code.
Framework components
To get started with the OpenEdge Logger Framework, follow these steps:
The logging.config file contains logging configurations in JSON format. It should be placed in the application’s PROPATH directory. Each configuration defines log levels and filters for specific ABL classes.
Example of basic logging.config file:
{
"logger": {
"com.example.myapp": {
"logLevel": "DEBUG",
"filters": ["json", "file"]
}
}
}
To use the Progress OpenEdge Logger framework in your ABL code:
Example:
DEFINE VARIABLE logger AS ILogWriter NO-UNDO.
logger = LoggerBuilder:GetLogger("com.example.myapp").
logger:Info("This is an informational message").
logger:Error("An error occurred").
Logging filters in the OpenEdge Logger Framework are essential for maintaining secure and efficient logging practices, especially when dealing with sensitive information. Filters allow developers to exclude, mask or modify data from log entries, ensuring compliance with security standards and protecting user privacy. You can apply custom rules to modify log output dynamically by configuring the Filter property in your logger definition.
To configure a logging filter, you will need to define it in your logging configuration file. Here is an example configuration snippet:
{
"logger": {
"myLog": {
"logLevel": "INFO",
"filters": [
"MDC_FORMAT",
{
"name": "ANON_FORMAT",
"hashAlgo": "SHA-512",
"tokensToAnon": "mdc.custId"
},
"REPLACE_TOKENS_FORMAT",
"FULL_TEXT_FORMAT",
{
"name": "NAMED_FILE_WRITER",
"fileName": "${session.temp-dir}/test.log",
"appendTo": false
}
]
}
}
}
Code example
Here is a sample implementation of a custom logging filter that masks Customer ID:
DEFINE VARIABLE oLogger AS ILogWriter NO-UNDO.
oLogger = LoggerBuilder:GetLogger('myLog').
oLogger:Info("Log Message without Sensitive Info.").
FIND FIRST Customer NO-LOCK NO-ERROR.
IF AVAILABLE Customer THEN
DO:
OpenEdge.Logging.MDC:Put("custId", STRING(Customer.CustNum)).
oLogger:Info("Customer found. Customer ID: $~{mdc.custId}").
END.
ELSE oLogger:Error("Customer not found!").
Output
After applying the filter, log messages containing sensitive data will be hashed. For example:
[2024-12-06T13:48:48.029+02:00] myLog INFO: Log Message without Sensitive Info.
[2024-12-06T13:48:48.035+02:00] myLog INFO: Customer found. Customer ID: $6$3RKhDX5uMJ7PFFeLeOhJ0A$89ER86Klq8W8yTUDio9Nsvz6M7vxyXIOi4QD7OM0ybnH1n/MA+3lsZtIabcdSPU4qnT7ucLvLX1isN1m2wI8NQ==
The OpenEdge Logger Framework provides a robust and flexible logging solution that allows for detailed configuration and customized log handling. It is ideal for applications that require advanced logging, such as managing different log levels, filtering messages, and separating log concerns between development and operations.
Both the LOG-MANAGER system handle and the OpenEdge Logger Framework offer valuable logging capabilities for Progress OpenEdge applications. The LOG-MANAGER system handle is simple and effective for basic logging needs, while the OpenEdge Logger Framework provides a more flexible, configurable approach to logging, allowing for advanced filtering, message formatting, and greater control over log behaviour.
For most scenarios requiring detailed and customisable logging, the OpenEdge Logger Framework is the recommended choice. However, the LOG-MANAGER system handle can be sufficient for simple logging tasks or when using legacy systems. By understanding the strengths and limitations of both options, you can choose the best approach for your OpenEdge application’s logging requirements.
Are you looking for some guidance in Progress OpenEdge development? Feel free to reach out to Baltic Amadeus.
Want to discuss potential opportunities? Pick the most suitable way to contact us.
Book a call+370 5 2 780 400
info@ba.lt
Find out what Microsoft Fabric is and how you can harness the potential of this platform to make strategic business decisions.
Read the blog post about Drupal, its different versions, and its benefits. Learn why Drupal migration is essential for your website.
Read the blog post about enterprise architecture. Learn about its key benefits, including risk management, regulatory compliance, and improved efficiency.