Previous Page | Next Page

Function Reference

Using the Logging Facility Functions in the DATA Step

SAS supplies three logging facility functions that you can use in the DATA step:

LOG4SAS_APPENDER

creates an appender. FileRefAppender is the only type of appender that can be created by using the SAS language.

LOG4SAS_LOGGER

logs a message by using a specific logger.

LOG4SAS_LOGEVENT

logs a message by using a specific logger.

You use logging facility functions in the same way as you use other functions in SAS: by assigning the function to a variable.

 rc=log4sas_appender("myAppenderName", "FileRefAppender", "fileref=myfiles");

When you create appenders and loggers, remember to create them only once in a DATA step, as in this example:

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

      rc=log4sas_logger("myLoggerName", "appender-ref=(myAppenderName) level=info");
      if rc ne 0 then do;
         msg = sysmsg();
         put msg;
         ABORT;
         end;
     end;

Previous Page | Next Page | Top of Page