Overview of Rolling Over the SAS Log: The SAS log can
get very large for long running servers and for batch jobs. By using
the LOGPARM= and LOG= system options together, you can specify to
roll over the SAS log to a new SAS log. When SAS rolls over the log,
it closes the log and opens a new log.
The LOGPARM= system
option controls when log files are opened and closed and the LOG=
system option names the SAS log file. Logs can be rolled over automatically,
when a SAS session starts, when the log has reached a specific size,
or not at all. By using formatting directives in the SAS log name,
each SAS log can be named with unique identifiers.
Using Directives to Name
the SAS Log: For the SAS log, a directive is a processing instruction
that is used to uniquely name the SAS log. By using directives, you
can add information to the SAS log name such as the day, the hour,
the system node name, or a unique identifier. You can include one
or more directives in the name of the SAS log when you specify the
log name in the LOG= system option. For example, if you want the SAS
log name to include the year, the month, and the day, the LOG= system
option might look like this:
-log='c:\saslog\#Y#b#dsas.log'
When the SAS log is created on February 2, 2009, the name of the
log is 2009Feb02sas.log.
Directives resolve only
when the value of the ROLLOVER= option of the LOGPARM= system option
is set to AUTO or SESSION. If directives are specified in the log
name and the value of the ROLLOVER option is NONE or a specific size,
n, the directive characters, such as #b or #Y,
become part of the log name. Using the example above for the LOG=
system option, if the LOGPARM= system option specifies ROLLOVER=NONE,
the name of the SAS log is #Y%b#dsas.log.
Automatically Rolling
Over the SAS Log When Directives Change: When the SAS log name contains
one or more directives and the ROLLOVER= option of the LOGPARM= system
option is set to AUTO, SAS closes the log and opens a new log when
the directive values change. The new SAS log name contains the new
directive values.
The follow table shows
some of the log names that are created when SAS is started on the
second of the month at 6:15 AM, using this SAS command:
sas -objectserver -log "london#n#d#%H.log"
-logparm
"rollover=auto"
The directive #n inserts
the system node name into the log name. #d adds the day of the month
to the log name. #H adds the hour to the log name. The node name for
this example is Thames. The log for this SAS session rolls over when
the hour changes and when the day changes.
Log Names for Rolled Over Logs
Rolling Over the SAS Log by SAS Session: To roll over
the log at the start of a SAS session, specify the LOGPARM=“ROLLOVER=SESSION”
option when SAS starts. SAS resolves the system-specific directives
by using the system information obtained when SAS starts. No roll
over occurs during the SAS session and the log file is closed at the
end of the SAS session.
Rolling Over the SAS Log by the
Log Size: To roll over the log when the log reaches a specific size,
specify the LOGPARM=“ROLLOVER=
n” option when SAS starts.
n is the maximum size of the log, in bytes, and it cannot be smaller
than 10K (10,240) bytes. When the log reaches the specified size,
SAS closes the log and appends the text “old” to the
filename. For example, londonold.log. SAS opens a new log using the
value of the LOG= option for the log name, ignoring the OPEN= option
of the LOGPARM= system option so that it never writes over an existing
log file. Directives in log names are ignored for logs that roll over
based on log size.
To ensure unique log
filenames between servers, SAS creates a lock file that is based
on the log filename. The lock filename is
logname.lck, where
logname is the
value of the LOG= option. If a lock file exists for a server log and
another server specifies the same log name, the log and lock filenames
for the second server have a number appended to the names. The numbers
begin with 2 and increment by 1 for subsequent requests for the same
log filename. For example, if a lock exists for the log file london.log,
the second server log would be london2.log and the lock file would
be london2.lck.
No SAS Log Roll Over: To not roll
over the log at all, specify the LOGPARM= “ROLLOVER=NONE”
option when SAS starts. Directives are not resolved and no rollover
occurs. For example, if LOG=“March#b.log”, the directive
#b does not resolve and the log name is March#b.log.