LOGPARM= System Option

Specifies when SAS log files are opened, closed, and, in conjunction with the LOG= system option, how they are named.
Valid in: Configuration file, SAS invocation
Category: Log and procedure output control: SAS log
PROC OPTIONS GROUP= LOGCONTROL
Restriction: LOGPARM= is valid only in line mode and in batch mode
Note: This option cannot be restricted by a site administrator. For more information, see Restricted Options.
See: LOGPARM= System Option: z/OS in SAS Companion for z/OS

Syntax

Syntax Description

OPEN=APPEND | REPLACE | REPLACEOLD
when a log file already exists, specifies how the contents of the existing file are treated.
APPEND
appends the log when opening an existing file. If the file does not already exist, a new file is created.
REPLACE
overwrites the current contents when opening an existing file. If the file does not already exist, a new file is created.
REPLACEOLD
replaces files that are more than one day old. If the file does not already exist, a new file is created.
Default:REPLACE
z/OS specifics:See the SAS documentation for your operating environment for limitations on the use of OPEN=REPLACEOLD.
ROLLOVER=AUTO|NONE|SESSION | n | nK | nM | nG
specifies when or if the SAS log “rolls over”. That is, when the current log is closed and a new one is opened.
AUTO
causes an automatic “rollover” of the log when the directives in the value of the LOG= option change, that is, the current log is closed and a new log file is opened.
Restriction:Rollover will not occur more often than once a minute.
Interactions:Rollover is triggered by a change in the value of the LOG= option.

The name of the new log file is determined by the value of the LOG= system option. If LOG= does not contain a directive, however, the name would never change, so the log would never roll over, even when ROLLOVER=AUTO.

NONE
specifies that rollover does not occur, even when a change occurs in the name that is specified with the LOG= option.
Interaction:If the LOG= value contains any directives, they do not resolve. For example, if Log="#b.log" is specified, the directive “#” does not resolve, and the name of the log file remains "#b.log".
SESSION
at the beginning of each SAS session, opens the log file, resolves directives that are specified in the LOG= system option, and uses its resolved value to name the new log file. During the course of the session, no rollover is performed.
n |nK |nM |nG
causes the log to rollover when the log reaches a specific size, stated in multiples of 1 (bytes); 1,024 (kilobytes); 1,048,576 (megabytes); or 1,073,741,824 (gigabytes). When the log reaches the specified size, it is closed and renamed by appending “old” to the log filename, and if it exists, the lock file for a server log. For example, a filename of mylog.log would be renamed mylogold.log. A new log file is opened using the name specified in the LOG= option.
Restriction:The minimum log file size is 10K.
Interaction:When a rollover occurs because of size and the LOG= value contains any directives, the directives do not resolve. For example, if Log="#b.log" is specified, the directive “#” does not resolve, and the name of the log file remains "#b.log".
Note:If you use ROLLOVER=n to roll over your files, the OPEN= parameter is ignored, and the initial log file is opened with OPEN=APPEND.
See:Rolling Over the SAS Log in SAS Language Reference: Concepts
CAUTION:
Old log files can be overwritten.
SAS maintains only one old log file with the same name as the open log file. If rollover occurs more than once, the old log file is overwritten.
Default:NONE
See:LOG System Option: UNIX in SAS Companion for UNIX Environments

LOG System Option: Windows in SAS Companion for Windows

LOG= System Option: z/OS in SAS Companion for z/OS

WRITE=BUFFERED | IMMEDIATE
specifies when content is written to the SAS log.
BUFFERED
writes content to the SAS log only when a buffer is full in order to increase efficiency.
IMMEDIATE
writes to the SAS log each time that statements are submitted that produce content for the SAS log. SAS does no buffering of log messages.
Default:BUFFERED
Windows specifics:The buffered log contents are written periodically, using an interval that is specified by SAS.

Details

The LOGPARM= system option controls the opening and closing of SAS log files when SAS is operating in batch mode or in line mode. This option also controls the naming of new log files, in conjunction with the LOG= system option and the use of directives in the value of LOG=.
Using directives in the value of the LOG= system option enables you to control when logs are open and closed and how they are named, based on actual time events, such as time, month, and day of week.
Operating Environment Information: Under the Windows and UNIX operating environments, you can begin directives with either the % symbol or the # symbol, and use both symbols in the same directive. For example, -log=mylog%b#C.log.Under z/OS, begin directives only with the # symbol. For example, -log=mylog#b#c.log.Under OpenVMS, begin directives only with the % symbol. For example, -log=mylog%b%c.log.
The following table contains a list of directives that are valid in LOG= values:
Directives for Controlling the Name of SAS Log Files
Directive
Description
Range
%a or #a
Locale's abbreviated day of week
Sun–Sat
%A or #A
Locale's full day of week
Sunday–Saturday
%b or #b
Local's abbreviated month
Jan–Dec
%B or #B
Locale's full month
January–December
%C or #C
Century number
00–99
%d or #d
Day of the month
01–31
%H or #H
Hour
00–23
%j or #j
Julian day
001–366
%l or #l 1
User name
alphanumeric string that is the name of the user that started SAS
%M or #M
Minutes
00–59
%m or #m
Month number
01–12
%n or #n
Current system node name (without domain name)
none
%p or #p 1
Process ID
alphanumeric string that is the SAS session process ID
%s or #s
Seconds
00–59
%u or #u
Day of week
1= Monday–7=Sunday
%v or #v 1
Unique identifier
alphanumeric string that creates a log filename that does not currently exist
%w or #w
Day of week
0=Sunday–6=Saturday
%W or #W
Week number (Monday as first day; all days in new year preceding first Monday are in week 00)
00–53
%y or #y
Year without century
00–99
%Y or #Y
Full year
1970–9999
%%
Percent escape writes a single percent sign in the log filename.
%
##
Pound escape writes a single pound sign in the log filename.
#
1Because %v, %l, and %p are not a time-based format, the log filename will never change after it has been generated. Therefore, the log will never roll over. In these situations, specifying ROLLOVER=AUTO is equivalent to specifying ROLLOVER=SESSION.
Operating Environment Information: See SAS Companion for z/OS for limitations on the length of the log filename under z/OS.
Note: Directives that you specify in the LOG= system option are not the same as the conversion characters that you specify to format logging facility logs. Directives specify a format for a log name. Conversion characters specify a format for log messages. Directives and conversion characters that use the same characters might function differently.
Note: If you start SAS in batch mode or server mode and the LOGCONFIGLOC= option is specified, logging is done by the SAS logging facility. The traditional SAS log option LOGPARM= is ignored. The traditional SAS log option LOG= is honored only when the %S{App.Log} conversion character is specified in the logging configuration file. For more information, see The SAS Logging Facility in SAS Logging: Configuration and Programming Reference.

Example

Operating Environment Information: The LOGPARM= system option is executed when SAS is invoked. When you invoke SAS at your site, the form of the syntax is specific to your operating environment. See the SAS documentation for your operating environment for details.
Rolling over the log at a certain time and using directives to name the log according to the time:
If this command is submitted at 9:43 AM, this example creates a log file called test0943.log, and the log rolls over each time the log filename changes. In this example, at 9:44 AM, the test0943.log file will be closed, and the test0944.log file will be opened.
sas -log "test%H%M.log" -logparm "rollover=auto"
Preventing log rollover but using directives to name the log:
For a SAS session that begins at 9:34 AM, this example creates a log file named test0934.log, and prevents the log file from rolling over:
sas -log "test%H%M.log" -logparm "rollover=session"
Preventing log rollover and preventing the resolution of directives:
This example creates a log file named test%H%M.log, ignores the directives, and prevents the log file from rolling over during the session:
sas -log "test%H%M.log" -logparm "rollover=none"
Creating log files with unique identifiers:
This example uses a unique identifier to create a log file with a unique name:
sas -log "test%v.log" -logparm "rollover=session" 
SAS replaces the directive %v with process_IDvn, where process_ID is a numeric process identifier that is determined by the operating system and n is an integer number, starting with 1. The letter v that is between process_ID and n is always a lowercase letter.
For this example, process_ID is 3755. If the file does not already exist, SAS creates a log file with the name test3755v1.log. If test3755v1.log does exist, SAS attempts to create a log file by incrementing n by 1, and this process continues until SAS can generate a log file. For example, if the file test3755v1.log exists, SAS attempts to create the file test3755v2.log.
Naming a log file by the user that started SAS:
This example creates a log filename that contains the user name that started the SAS session:
sas -log "%l.log" -logparm "rollover=session";

See Also

The SAS Log in SAS Language Reference: Concepts