%LOG4SAS_APPENDER Autocall Macro

Defines an appender.
Category: Logging
Requirements: The MAUTOSOURCE system option must be set.
The %LOG4SAS autocall macro must be invoked before this macro is invoked to initialize the logging facility autocall macros.
Arguments that follow the FileRefAppender argument must be enclosed as a group in single quotation marks.

Syntax

%LOG4SAS_APPENDER(name, "FileRefAppender"
<,'<FILEREF=fileref> <PATTERN="pattern"> <THRESHOLD=threshold> '>
)

Syntax Description

name
specifies the name of the appender.
Tip Appender names are case sensitive.
"FileRefAppender"
specifies the FileRefAppender class to which the defined appender belongs.
Note: This is the only supported appender class. More appender classes might be supported in the future.
Requirements Appender classes are case sensitive. In this instance, the class name must be FileRefAppender.
FileRefAppender must be enclosed in double quotation marks.
FILEREF=fileref
specifies the destination for log events that the FileRefAppender class processes.
PATTERN="pattern"
specifies the conversion pattern that is used to format the log message.
Requirement The pattern must be enclosed in double quotation marks.
Tip If PATTERN is not specified, the default is the message.
THRESHOLD=threshold
specifies the level at which log events are filtered out for the FileRefAppender. Valid values are TRACE, DEBUG, INFO, WARN, ERROR, and FATAL.

Details

Appender Names

The name argument of the appender is specified as the value in the APPENDER-REF argument in the %LOG4SAS_LOGGER autocall macro. Here is an example:
filename myfile "my.log";
%log4sas();
%log4sas_appender(myAppender,"FileRefAppender",'fileref=myfile');
%log4sas_logger(testlogger, 'level=info appender-ref=(myAppender)');

Patterns

Patterns are a feature of SAS logging that enables you to associate a layout with a particular logging output destination. The layout specifies how the output is formatted before it is sent to the output destination. The layout is specified as a pattern string that is similar to the pattern strings that are used in the C language PRINTF statement. The pattern layout contains literal text and format directives that are called conversion specifiers.
Each conversion specifier has the following syntax:
%[format_modifiers] conversion_character
If a pattern is not specified, the default pattern contains just the application message.
For more information, seePattern Layouts.

Thresholds

An appender can be configured to have a threshold level. By default, appenders do not have a threshold set. When a threshold is set, all log events that have a level that is lower than the threshold level are ignored by the appender.
For more information, see Logging Thresholds.

Example

The following appender definition names the appender debugMyProgram, names a log message destination using the fileref debugOut, and specifies a pattern that reports the filename and the line number of the application that generated the log event:
filename debugOut="c:\myDebugOutput.txt";
%log4sas();
%log4sas_appender(debugMyProgram, "FileRefAppender",
                  'fileref=debugOut pattern="(%F:%L)%m" threshold=trace');