Previous Page | Next Page

Logger Reference

SAS Logger Overview and Syntax

Logger Overview

A logger names a specific message category and associates the message category with a message level and one or more appenders that process the log message.

In a logging facility XML configuration file and in a SAS program, an appender that is specified as an appender reference in a logger must be defined before the logger is defined.

For more information about loggers, see Loggers.

Logger Syntax

XML Configuration
<logger name="logger-name">
<level value="TRACE | DEBUG | INFO | WARN | ERROR | FATAL"/>
<appender-ref ref="appender-name"/>

Logger Syntax Description


specifies the name of a message category. The value of logger-name is case sensitive and can be a single name or a hierarchical name. Use a period to separate hierarchical names. Quotation marks are required.

Default: None
Required: Yes
level value="TRACE | DEBUG | INFO | WARN |ERROR | FATAL"

specifies the lowest event level that is processed by this logger. Log events that have messages that are below the specified level are ignored. The valid level values are listed here from lowest to highest. If a level is not specified, SAS uses the level of the next highest parent logger that defines a level. Quotation marks are required.

Required: No
Default: None
See: Logging Thresholds
appender-ref ref="appender-name"

specifies the name of an appender whose destination receives messages for log events that are specified for this logger. The value of appender-name must be defined in the XML configuration file. You can define multiple appenders for a logger.

Logger Examples

Example 1: Define a Logger to Log Error Messages for an Application in Production

This example creates a logger to record error log events for an application that is in production. The appender ApplProduction_Appender must also be defined in the XML configuration file.

<logger name="ApplProduction_Logger">
   <level value="error"/>
   <appender-ref ref="ApplProduction_Appender"/>

Example 2: Define Loggers That Inherit the Level

In this configuration example, IOMSrv is the parent logger for IOMSrv.Workspace and IOMSrv.Metadata. The IOMSrv.Workspace logger and the IOMSrv.Metadata logger do not define a level. Therefore, they inherit the level of the closest parent, which is IOMSrv. IOMSrv defines a level of error. Log events for the IOMSrv.Workspace and the IOMSrv.Metadata message categories use the level of error and write error and fatal messages to their respective appender destinations.

<logger name="IOMSrv">
   <level value="error"/>

<logger name="IOMSrv.Workspace">
   <appender-ref ref="WorkspaceLog"/>

logger name="IOMSrv.Metadata">
   <appender-ref ref="MetadataLog"/>

Previous Page | Next Page | Top of Page