Previous Page | Next Page

Logger and Appender Object Language Reference

DECLARE Statement, Appender Object



Declares an appender object; creates an instance of an appender object and initializes data for an appender object.
Valid in: DATA step
Category: Action
Type: Executable
Alias: DCL

Syntax
Arguments
Details
Appender Names
FileRefAppender
Patterns
Thresholds
Examples
See Also

Syntax

DECLARE APPENDER ("name", "FileRefAppender", "FILEREF =fileref"
<, PATTERN: "pattern"> <, THRESHOLD: "threshold">);


Arguments

name

specifies the name of the appender object.

Requirement: The name must be enclosed in double quotation marks.
Interaction: This name is valid for use wherever an AppenderRef is accepted (for example, in the DECLARE statement for the logger object).
Tip: Appender names are case sensitive.
FileRefAppender

specifies the FileRefAppender class to which the defined appender instance belongs.

Note:   This is the only supported appender class. More appender classes might be supported in the future.  [cautionend]

Requirement: Appender class names are case sensitive. In this instance, the name must be "FileRefAppender".
Requirement: FileRefAppender must be enclosed in double quotation marks.
FILEREF="fileref"

specifies the destination for log events that the FileRefAppender class processes.

Requirement: If the FileRefAppender argument is specified, this argument also must be specified.
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 a conversion pattern is not specified, the log event produces an empty string.
THRESHOLD: "threshold"

specifies the level at which log events are filtered out for the specified appender object. Valid values are TRACE, DEBUG, INFO, WARN, ERROR, and FATAL.

Requirement: The level must be enclosed in double quotation marks.

Details


Appender Names

Appender names follow the rules for SAS naming conventions. For appender objects, the name can be referenced by the logger object in the APPENDERREF attribute. For more information, see APPENDERREF Attribute. Here is an example:

filename myfile "my.log";
declare appender appobj("workappd", "FileRefAppender", "FileRef=myfile");
declare logger logobj("testlog");
logobj.appenderref="workappd";


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 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 the log message only.

For more information, see Overview of Pattern 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.


Examples

This example creates an appender object.

data _null_;
   if _n_ = 1 then do;
      declare appender appobj("testappd", "FileRefAppender", "fileref=testfref", 
              pattern:"%nrstr(%d{yyyMMdd:HH.mm.ss.SS}: %t:%8p %m)", threshold:"fatal");
   end;
run;


See Also

Attribute:

APPENDERREF Attribute

Statement:

DECLARE Statement, Logger Object

Previous Page | Next Page | Top of Page