Open System Services Library Calls Reference Manual (G06.29+, H06.08+, J06.03+)
OSS Library Calls (n - r) openlog(3)
LOG_NEWS Messages generated by a network news subsystem.
LOG_SYSLOG
Messages generated by a syslogd daemon.
LOG_UUCP Messages generated by a UNIX-to-UNIX copy program (UUCP)
subsystem.
DESCRIPTION
The openlog( ) function changes logging actions if special processing is needed for an event mes-
sage. For example, the LOG_CONS option of the logopt parameter determines the action taken
by the syslog( ) function when it is unable to send an event message to the collector specified by
the EMS_COLLECTOR environment variable (if the application is started from the OSS
environment) or the Guardian EMSˆCOLLECTOR PARAM (if the application is started from
the Guardian environment). The openlog( ) function can also override the default facility and
event subject using the facility and ident parameters.
Because the syslog( ) function automatically opens the connection to the collector if one is not
already open, it is not necessary to call openlog( ) before calling syslog( ). However, if open-
log( ) is called when the calling process already has a log file open, the current log file is closed.
Note: The openlog( ) function changes the default facility only if the facility parameter is
not 0 (zero). Because the facility option LOG_KERN has the value 0 (zero), a bit
outside of the facility field within the facility parameter must be set to 1 so that
openlog( ) changes the default facility to 0 (zero). To use the facility option
LOG_KERN as the default facility, logically OR that symbolic value with a 1.
Use From the Guardian Environment
The openlog( ) function can be called from the Guardian environment. However, the logopt
value LOG_PID cannot be used from the Guardian environment because a Guardian process
does not have an OSS process ID. If openlog( ) is called from the Guardian environment with a
logopt value of LOG_PID, the function causes a Guardian trap 5 to occur.
If you use the Guardian EMSˆCOLLECTOR PARAM, the value of the Guardian SAVE-
ENVIRONMENT PARAM must be ON. For applications that have the main routine written in
C, ON is the default value for the SAVE-ENVIRONMENT PARAM. For more information
about the Guardian SAVE-ENVIRONMENT PARAM, see the Common Run-Time Environment
(CRE) Programmer’s Guide.
If you use the Guardian EMSˆCOLLECTOR PARAM and the Guardian SAVE-
ENVIRONMENT PARAM is OFF, the openlog( ) function takes the same actions as it does
when the Guardian EMSˆCOLLECTOR PARAM is not set.
RETURN VALUES
The openlog( ) function always returns 0 (zero) unless the LOG_NDELAY option of the logopt
parameter is specified. In that case, openlog( ) tries to open a connection to the collector specified
by the EMS_COLLECTOR environment variable (if the application is started from the OSS
environment) or the Guardian EMSˆCOLLECTOR PARAM (if the application is started from
the Guardian environment).
If openlog( ) cannot open a connection to the user-specified collector but the LOG_CONS option
of logopt is specified, a connection to the primary collector ($0) is opened and the function
returns the value 0 (zero).
If openlog( ) cannot open a connection to the user-specified collector and the LOG_CONS
option is not specified, the function returns the value -1 and errno is not set.
527187-017 Hewlett-Packard Company 5−43