Log filters
- Last Updated: October 21, 2024
- 6 minute read
- OpenEdge
- Version 12.8
- 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
- Uses the OpenEdge.Logging.Format.ABLSubstituteFormat
to provide standard text substitutions such as those used by the
SUBSTITUTEfunction in ABL. Use this filter if the log event'sLogMessageobject 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
- Uses the OpenEdge.Logging.Format.AnonymizedTokenFormat to anonymize certain ABL variables using a specified (or default) hashing algorithm before output.
- ERROR_FORMAT
- Uses the OpenEdge.Logging.Format.ErrorFormat to write any errors
raised in a verbose and specific format, including a call stack when
present. 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
- Uses the OpenEdge.Logging.Format.FullTextFormat to
provide a more verbose, standardized log format:
[timestamp] logger-short-name log-level: log-message. Here is a sample output: - LOG_MANAGER_FORMAT
- Uses the OpenEdge.Logging.Format.LogManagerFormat to
provide a simple, standardized log format:
[logger-short-name log-level] log-message. Use this filter if you want the same log message format that is used in theLOG-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. - MDC_FORMAT
- Uses the OpenEdge.Logging.Format.MDCTokenFormat to
write Mapped Diagnostic Context-based tokens as represented by
${mdc.context-key}in the custom message string. - REPLACE_TOKENS_FORMAT
- Uses the OpenEdge.Logging.Format.TokenContextFormat
to enable more standard token values, such as timestamps and
SESSIONproperties, to be replaced when provided with a custom message string. Tokens exist as a group name plus optional arguments separated by a".", such as${t.now}which resolves to the[T]imegroup with an argument of"now"resulting in the current timestamp represented as an ISO-DATE with a date, time, and timezone.Note: See the OpenEdge.Core.Util.TokenResolver class for a comprehensive list of available tokens. - STACK_WRITER_FORMAT
- Uses the OpenEdge.Logging.Format.StackWriterFormat to write a message
in addition to a call stack, if one is present. 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
- Uses the OpenEdge.Logging.Format.ResolvedTokenFormat
to enable use of a customized, token-based message statement. Use this
filter if you want to use tokens in the log message. Note: By defaultA token is like a placeholder or a variable name, whose value is 'resolved' at runtime. For example, if you use the token
TOKEN_FORMATonly provides support for the message itself as the token${msg.msg}and is typically used with theREPLACE_TOKENS_FORMAT.${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
- Uses the OpenEdge.Logging.Writer.JsonLogWriter to write all log
messages in a structured JSON format.
JsonLogWriterappends all messages to a JSON array in application memory. This data must be programmatically written or cleared as necessary. - LOG_MANAGER_WRITER
- Uses the OpenEdge.Logging.Writer.LogManagerWriter to
write messages directly to the log files used by the ABL
LOG-MANAGERsession handle. Specify this filter as shown in this example."filters": [ "FULL_TEXT_FORMAT", "LOG_MANAGER_WRITER" ] - MSG_STMT_WRITER
- Uses the OpenEdge.Logging.Writer.MessageStatementWriter to
immediately output a log message via the
MESSAGEstatement. Specify this filter as shown in this example. - NAMED_FILE_WRITER
- Uses the OpenEdge.Logging.Writer.NamedFileWriter to write messages to a custom log file. This writer attempts to create any subdirectories up to the given filename. Specify this filter as shown in this example.
- VOID_WRITER
- Uses the OpenEdge.Logging.Writer.VoidWriter to send
messages to a null output. Use this filter if you want to turn off
writing log messages. The
VOID_WRITERfilter acts as a sink for theLogEventobject.