Logger and Appender Object Language Reference |
Valid in: | DATA step |
Category: | Action |
Type: | Executable |
Alias: | DCL |
Syntax | |
Arguments | |
Details | |
Logger Names | |
Additivity | |
Levels | |
Examples | |
See Also |
Syntax |
DECLARE LOGGER ("name" <, ADDITIVITY: TRUE | FALSE><, LEVEL:
"level">
<, APPENDERREF:" appender-name"<..., APPENDERREF: "appender-name">>); |
specifies the name of the logger object.
Requirement: | The name must be enclosed in double quotation marks. |
Tip: | You can specify the root logger by setting name equal to either double quotation marks with no space between them (" "), or to "root". If you specify the root logger, these settings are in effect only during the lifespan of the DATA step. Root settings before and after the DATA step are based on the logging configuration file. |
specifies whether to pass a log event only to the appender that is associated with the logger or to all the appenders in the logger's hierarchy.
Tip: | You can also specify this optional argument by using the ADDITIVITY Attribute after the logger instance has been created. |
specifies the name of the appender to which log events are passed.
Requirement: | The appender name must already exist. Appender names are created by using the DECLARE Statement, Appender Object. |
Interaction: | If the ADDITIVITY argument is set to TRUE, the log events are also passed to all the appenders that are associated with the logger's hierarchy. |
Tip: | You can specify more than one appender for each logger. |
Tip: | You can also specify this optional argument by using the APPENDERREF attribute after the logger instance has been created. For more information, see APPENDERREF Attribute. |
specifies the level at which a logging request is applied for the specified logger object. Valid values are TRACE, DEBUG, INFO, WARN, ERROR, and FATAL.
Requirement: | The level must be enclosed in double quotation marks. |
Tip: | You can also specify this optional argument by using the LEVEL Attribute after the logger instance has been created. |
Details |
A logger instance is said to be an ancestor of another logger instance if the logger instance name, followed by a dot, is the prefix of the other logger.
In the following example, IOM is the parent logger, IOM is an ancestor of the APP logger, and both IOM and APP are ancestors of the WORKSPACE logger.
logobj.name="IOM"; logobj.name="IOM.APP"; logobj.name="IOM.APP.WORKSPACE";
The hierarchical organization of loggers enables them to inherit log event levels and appenders from their ancestors.
By default, each log event is passed to the appenders that are associated with the logger and to the appenders that are associated with the logger's hierarchy. This is the meaning of the term appender additivity.
For example, assume that you have a logger, CONSOLE. The output of a log event of logger CONSOLE goes to all of the appenders that are in CONSOLE and its ancestors. However, if an ancestor of logger CONSOLE, say FILE, has the additivity flag set to FALSE, then CONSOLE's output is directed to all of the appenders that are in CONSOLE and its ancestors up to and including FILE, but not the appenders in any of the ancestors of FILE.
A logging request is applied if its level is greater than the level of the logger. Otherwise, the logging request is ignored. Loggers that do not have an explicitly assigned level inherit their level from the hierarchy. For more information about the logging levels, see Logging Thresholds.
Examples |
The following example creates a logger object, mylog.
data _null_; if _n_ = 1 then do; declare appender appobj("myappd", "FileRefAppender", "fileref=myfref"); appobj.threshold="trace"; declare logger logobj("mylog"); logobj.appenderref="myappd"; end; logobj.level="trace"; logobj.debug("Test debug message"); logobj.level="info"; logobj.info("Test info message"); run;
See Also |
Attribute: | |||||||
Statement: |
Copyright © 2010 by SAS Institute Inc., Cary, NC, USA. All rights reserved.