Log filters
- Last Updated: May 6, 2024
- 5 minute read
- OpenEdge
- Version 12.2
- Documentation
Filters process log events that satisfy the log level defined in the same configuration. The OpenEdge Logger framework provides a number of built-in filters. They fall into two broad categories:
- Format filters that format the log message. You can define multiple format filters in the same logging configuration. In this case, the filters are applied to each log event sequentially, in the order in which you define them.
- Writer filters that write the log message to a file or console. Just like format filters, you can define multiple writer filters in the same logging configuration. In this case, the log message gets written by each writer filter.
You must use at least one format filter before a writer filter. Here is a list of built-in filters for each category:
Format Filters
- ABL_SUBSTITUTE_FORMAT
- Use this filter if the log event's
LogMessageobject contains arguments whose values are retrieved from elements in an array. Specify the filter name as shown in this example. No additional properties need to be set. - ANON_FORMAT
- Use this filter to make values anonymous using a hash function.
- ERROR_FORMAT
- This filter applies only to log events produced by the
Error()method. The log event that is produced includes a property namedError. This property (populated only for log events produced byError()), is of the typeProgress.Lang.Errorand contains a description of the error.Note: Using theSpecify this filter as shown in this example. No additional properties need to be set.ERROR_FORMATfilter sets the session'serror-stack-traceproperty totrue. - FULL_TEXT_FORMAT
- This filter produces a predefined format that includes the timestamp, message group (if available), log level, the logging configuration name, and the log message. Here is a sample output:
- LOG_MANAGER_FORMAT
- Use this filter if you want the same log message format
that is used in the
Log-Manager. In this format, the log level is prefixed in the log message. Specify the filter name as shown in this example. No additional properties need to be set. - STACK_WRITER_FORMAT
- This filter applies to log events produced by the
Debug()method. The log event that is produced includes a property namedCallStack. This property (populated only for log events produced byDebug()) contains log stack information about the classes and methods that led to the log event. Specify this filter as shown in this example. No additional properties need to be set. - TOKEN_FORMAT
- Use this filter if you want to use tokens in the log
message. A token is like a placeholder or a variable name, whose value is
'resolved' at runtime. For example, if you use the token
${t.now}, theTOKEN_FORMATfilter resolves the token to the current timestamp (the time at which the filter was applied). You cannot add tokens while defining log messages in the ABL class. You can, however, define a token in theTOKEN_FORMATfilter as shown in this example.
Writer filters
- DEFAULT_WRITER
- Use this filter to use the default logging system. For PAS
for OpenEdge, this resolves to the
LOG_MANAGER_WRITER. For other client types, it resolves toVOID_WRITER. - JSON_LOG_WRITER
- Use this filter to write all log messages in a structured JSON format.
- LOG_MANAGER_WRITER
- Use this filter to write log messages to the log files used
by the ABL
Log-Manager(typically the PAS for OpenEdge agent log). Specify this filter as shown in this example."filters": [ "FULL_TEXT_FORMAT", "LOG_MANAGER_WRITER" ] - NAMED_FILE_WRITER
- Use this filter to specify the name of a log file to write the log message to. Specify this filter as shown in this example.
- VOID_WRITER
- Use this filter if you want to turn off writing log
messages. The
VOID_WRITERfilter acts as a sink for theLogEventobject.