Previous Page | Next Page

Function Reference

LOG4SAS_APPENDER Function



Creates a fileref appender that can be referenced by a logger.
Category: Logging
Featured in:: Logging Example Using Functions

Syntax
Arguments
Details
Appender Names
FileRefAppender
Patterns
Thresholds
Processing Appenders in the DATA Step
See Also

Syntax

LOG4SAS_APPENDER("name", "FileRefAppender", 'options')


Arguments

"name"

specifies a name for the appender.

Tip: The appender name is case sensitive.
"FileRefAppender"

specifies that a fileref is used as the destination for the appender.

'options'

specify one or more of the following values:

FILEREF=fileref

specifies a fileref that is used as the log message destination for this appender.

Required: Yes
PATTERN="pattern"

specifies one or more message layout patterns that are used to format the log message.

See: Pattern Layout
THRESHOLD="threshold"

specifies a level at which log events that are lower than threshold are filtered out for the appender. Valid values for threshold, from lowest to highest, are TRACE, DEBUG, INFO, WARN, ERROR, and FATAL.

Requirement: Options must be enclosed in single quotation marks.

Details


Appender Names

Appender names follow SAS naming conventions. An appender is associated to a logger by using the appender name as one of the values of the APPENDER-REF option in the LOG4SAS_LOGGER function.


FileRefAppender

A FileRefAppender is the only type of appender that can be used in the SAS language.


Patterns

Patterns are a feature of SAS logging that enable 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 log message.

For more information, see Pattern Layout.


Thresholds

An appender can be defined to have a threshold level. By default, appenders do not have a threshold. 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.


Processing Appenders in the DATA Step

An appender needs to be created only one time for each DATA step. Because the DATA step uses the implicit loop to process observations in a data set, you can use the automatic variable _N_ in an IF statement to process the LOG4SAS_APPENDER function during the first DATA step iteration:

if _n_ = 1 then 
   do;
      rc=log4sas_appender("myAppenderName", "FileRefAppender", "fileref=myfiles");
      if rc ne 0 then do;
         msg = sysmsg();
         put msg;
         ABORT;
         end;
   end;


See Also

Functions:

LOG4SAS_LOGGER Function

LOG4SAS_LOGEVENT Function

Previous Page | Next Page | Top of Page