Open System Services Library Calls Reference Manual (G06.28+, H06.05+)

openlog(3) OSS Library Calls Reference Manual
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 specied by
the EMS_COLLECTOR environment variable. openlog() 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 le open, the current log le 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 eld 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.
RETURN VALUES
The openlog() function always returns 0 (zero) unless the LOG_NDELAY option of the logopt
parameter is specied. In that case, openlog() tries to open a connection to the collector specied
by the EMS_COLLECTOR environment variable. If openlog() cannot open a connection to
that collector but the LOG_CONS option of logopt is specied, a connection to the primary col-
lector ($0) is opened and the function returns the value 0 (zero).
If openlog() cannot open a connection to the user-specied collector and the LOG_CONS
option is not specied, the function returns the value -1 and errno is not set.
RELATED INFORMATION
Functions: closelog(3), setlogmask(3), syslog(3).
Commands: logger(1).
STANDARDS CONFORMANCE
The HP implementation of this function does not conform to the XPG4 Version 2 specication
because the function returns a value.
The following are HP extensions to the XPG4 Version 2 specication:
The symbolic values LOG_AUTH, LOG_CRON, LOG_DAEMON, LOG_KERN,
LOG_LPR, LOG_NEWS, LOG_SYSLOG, and LOG_UUCP are allowed for facility
options.
526 Hewlett-Packard Company 527187-007