| Skip Navigation Links | |
| Exit Print View | |
![]() | man pages section 3: Basic Library Functions Oracle Solaris 11 Information Library |
enable_extended_FILE_stdio(3C)
posix_spawnattr_getschedparam(3C)
posix_spawnattr_getschedpolicy(3C)
posix_spawnattr_getsigdefault(3C)
posix_spawnattr_getsigignore_np(3C)
posix_spawnattr_getsigmask(3C)
posix_spawnattr_setschedparam(3C)
posix_spawnattr_setschedpolicy(3C)
posix_spawnattr_setsigdefault(3C)
posix_spawnattr_setsigignore_np(3C)
posix_spawnattr_setsigmask(3C)
posix_spawn_file_actions_addclose(3C)
posix_spawn_file_actions_addclosefrom_np(3C)
posix_spawn_file_actions_adddup2(3C)
posix_spawn_file_actions_addopen(3C)
posix_spawn_file_actions_destroy(3C)
posix_spawn_file_actions_init(3C)
pthread_attr_getdetachstate(3C)
pthread_attr_getinheritsched(3C)
pthread_attr_getschedparam(3C)
pthread_attr_getschedpolicy(3C)
pthread_attr_setdetachstate(3C)
pthread_attr_setinheritsched(3C)
pthread_attr_setschedparam(3C)
pthread_attr_setschedpolicy(3C)
pthread_barrierattr_destroy(3C)
pthread_barrierattr_getpshared(3C)
pthread_barrierattr_setpshared(3C)
pthread_condattr_getpshared(3C)
pthread_condattr_setpshared(3C)
pthread_cond_reltimedwait_np(3C)
pthread_key_create_once_np(3C)
pthread_mutexattr_getprioceiling(3C)
pthread_mutexattr_getprotocol(3C)
pthread_mutexattr_getpshared(3C)
pthread_mutexattr_getrobust(3C)
pthread_mutexattr_setprioceiling(3C)
pthread_mutexattr_setprotocol(3C)
pthread_mutexattr_setpshared(3C)
pthread_mutexattr_setrobust(3C)
pthread_mutex_getprioceiling(3C)
pthread_mutex_reltimedlock_np(3C)
pthread_mutex_setprioceiling(3C)
pthread_rwlockattr_destroy(3C)
pthread_rwlockattr_getpshared(3C)
pthread_rwlockattr_setpshared(3C)
pthread_rwlock_reltimedrdlock_np(3C)
pthread_rwlock_reltimedwrlock_np(3C)
pthread_rwlock_timedrdlock(3C)
pthread_rwlock_timedwrlock(3C)
rctlblk_get_enforced_value(3C)
- control system log
#include <syslog.h>voidopenlog(const char *ident,intlogopt,intfacility);
voidsyslog(intpriority,const char *message,.../*arguments */);
voidcloselog(void);
intsetlogmask(intmaskpri);
Thesyslog() function sends a message tosyslogd(1M), which, depending on theconfiguration of/etc/syslog.conf, logs it in an appropriate system log, writes it tothe system console, forwards it to a list of users, or forwardsit tosyslogd on another host over the network. The loggedmessage includes a message header and a message body. The messageheader consists of a facility indicator, a severity level indicator, a timestamp, atag string, and optionally the process ID.
The message body is generated from themessage and following arguments inthe same manner as if these were arguments toprintf(3C), except that occurrencesof%m in the format string pointed to by themessage argumentare replaced by the error message string associated with the current valueoferrno. A trailing NEWLINE character is added if needed.
Symbolic constants for use as values of thelogopt,facility,priority, andmaskpri arguments are defined in the <syslog.h> header.
Values of thepriority argument are formed by ORing together aseverity levelvalue and an optionalfacility value. If no facility value isspecified, the current default facility value is used.
Possible values of severity level include, in decreasing order:
A panic condition. This is normally broadcast to all users.
A condition that should be corrected immediately, such as a corrupted system database.
Critical conditions, such as hard device errors.
Errors.
Warning messages.
Conditions that are not error conditions, but that may require special handling.
Informational messages.
Messages that contain information normally of use only when debugging a program.
The facility indicates the application or system component generating the message. Possible facility values include:
Messages generated by the kernel. These cannot be generated by any user processes.
Messages generated by random user processes. This is the default facility identifier if none is specified.
The mail system.
System daemons.
The authentication / security / authorization system:login(1),su(1M),getty(1M).
Designated for the USENET network news system.
Designated for the UUCP system; it does not currently usesyslog().
Thecron/at facility;crontab(1),at(1),cron(1M).
The audit facility, for example,auditd(1M).
Designated for local use.
Designated for local use.
Designated for local use.
Designated for local use.
Designated for local use.
Designated for local use.
Designated for local use.
Designated for local use.
Theopenlog() function sets process attributes that affect subsequent calls tosyslog().Theident argument is a string that is prepended to every message.Theopenlog() function uses the passed-inident argument directly, rather than makinga private copy of it. Thelogopt argument indicates logging options. Values forlogopt are constructed by a bitwise-inclusive OR of zero ormore of the following:
Log the process ID with each message. This is useful for identifying specific daemon processes (for daemons that fork).
Write messages to the system console if they cannot be sent tosyslogd(1M). This option is safe to use in daemon processes that have no controlling terminal, sincesyslog() forks before opening the console.
Open the connection tosyslogd(1M) immediately. Normally the open is delayed until the first message is logged. This is useful for programs that need to manage the order in which file descriptors are allocated.
Delay open untilsyslog() is called.
Do not wait for child processes that have been forked to log messages onto the console. This option should be used by processes that enable notification of child termination usingSIGCHLD, sincesyslog() may otherwise block waiting for a child whose exit status has already been collected.
Thefacility argument encodes a default facility to be assigned to allmessages that do not have an explicit facility already encoded. Theinitial default facility isLOG_USER.
Theopenlog() andsyslog() functions may allocate a file descriptor. Itis not necessary to callopenlog() prior to callingsyslog().
Thecloselog() function closes any open file descriptors allocated by previous callstoopenlog() orsyslog().
Thesetlogmask() function sets the log priority mask for the current processtomaskpri and returns the previous mask. If themaskpri argumentis 0, the current log mask is not modified. Calls bythe current process tosyslog() with a priority not set inmaskpri arerejected. The mask for an individual prioritypri is calculated bythe macroLOG_MASK(pri); the mask for all priorities up to and includingtoppriis given by the macroLOG_UPTO(toppri). The default log mask allows allpriorities to be logged.
Thesetlogmask() function returns the previous log priority mask. Thecloselog(),openlog()andsyslog() functions return no value.
No errors are defined.
Example 1 Example ofLOG_ALERT message.
This call logs a message at priorityLOG_ALERT:
syslog(LOG_ALERT, "who: internal error 23");
The FTP daemonftpd would make this call toopenlog() to indicatethat all messages it logs should have an identifying string offtpd,should be treated bysyslogd(1M) as other messages from system daemons are,should include the process ID of the process logging the message:
openlog("ftpd", LOG_PID, LOG_DAEMON);Then it would make the following call tosetlogmask() to indicate thatmessages at priorities fromLOG_EMERG throughLOG_ERR should be logged, but thatno messages at any other priority should be logged:
setlogmask(LOG_UPTO(LOG_ERR));
Then, to log a message at priorityLOG_INFO, it would make thefollowing call tosyslog:
syslog(LOG_INFO, "Connection from host %d", CallingHost);
A locally-written utility could use the following call tosyslog() to loga message at priorityLOG_INFO to be treated bysyslogd(1M) as othermessages to the facilityLOG_LOCAL2 are:
syslog(LOG_INFO|LOG_LOCAL2, "error: %m");
Seeattributes(5) for descriptions of the following attributes:
|
at(1),crontab(1),logger(1),login(1),auditd(1M),cron(1M),getty(1M),su(1M),syslogd(1M),printf(3C),syslog.conf(4),attributes(5),standards(5)
Copyright © 2011, Oracle and/or its affiliates. All rights reserved.Legal Notices | ![]() ![]() |