When you create a logger in
the SAS language, you create a category for messages that are logging
messages. The message category is user-specified and is meaningful
in your environment for the types of messages that you want to log.
For example, if you are testing an existing SAS program where you
have added new functionality, you might want messages in preexisting
code to be logged as regression messages. Log messages for new code
could be logged as new feature messages. Other logger categories might
include department names, SAS program names, or analytical model names.
For an example of logger category definitions, see
Example of Creating Logger and Appender Categories.
Message categories that
you create in the SAS language differ from the types of message categories
for SAS servers in that the SAS language message categories are user-defined,
and the SAS server message categories are defined by SAS.
You can create message
categories in a hierarchy where the hierarchy levels are separated
by a . (period). Here are examples: IT, IT.Pgm1, and IT.Pgm2. The
attributes that are defined in the higher-level logger can be used
by lower-level loggers when the lower-level logger does not define
an attribute. For example, you could create a high-level logger IT
for your IT department. The logger IT specifies the level as INFO.
Loggers IT.Pgm1 and IT.Pgm2 do not specify a level attribute. Therefore,
they inherit the level of the next highest logger, which in this case
is IT. Because the logger IT specifies the level as INFO, when a log
event specifies the IT.Pgm1 or IT.Pgm2 logger, the logger level INFO
is compared to the log event message level. The logger definitions
in this scenario might look like the following functions:
/* Create the context for logging regression messages. */
/* Regression log events of level info or higher are written * /
/* to the destination, specified by the appender to be defined as ITPgmRegression. */
if _n_=1 then
do;
rc=log4sas_logger("IT", "appender-ref=(ITPgmRegression) level=info");
if rc ne 0 then do
msg = sysmsg();
put msg;
ABORT;
end;
end;
/* Create the context for Pgm1 in the IT department. */
/* Do not specify a level; use the IT logger level. */
if _n_=1 then
do;
rc=log4sas_logger("IT.Pgm1", "appender-ref=(ITPgm1Regression)");
if rc ne 0 then do
msg = sysmsg();
put msg;
ABORT;
end;
end;
/* Create the context for Pgm2 in the IT department. */
/* Do not specify a level; use the IT logger level. */
if _n_=1 then
do;
rc=log4sas_logger("IT.Pgm2", "appender-ref=(ITPgm2Regression)");
if rc ne 0 then do
msg = sysmsg();
put msg;
ABORT;
end;
end;