17
18 \fBvoid\fR \fBopenlog\fR(\fBconst char *\fR\fIident\fR, \fBint\fR \fIlogopt\fR, \fBint\fR \fIfacility\fR);
19 .fi
20
21 .LP
22 .nf
23 \fBvoid\fR \fBsyslog\fR(\fBint\fR \fIpriority\fR, \fBconst char *\fR\fImessage\fR, \fB\&.../*\fR \fIarguments\fR */);
24 .fi
25
26 .LP
27 .nf
28 \fBvoid\fR \fBcloselog\fR(\fBvoid\fR);
29 .fi
30
31 .LP
32 .nf
33 \fBint\fR \fBsetlogmask\fR(\fBint\fR \fImaskpri\fR);
34 .fi
35
36 .SH DESCRIPTION
37 .sp
38 .LP
39 The \fBsyslog()\fR function sends a message to \fBsyslogd\fR(1M), which,
40 depending on the configuration of \fB/etc/syslog.conf\fR, logs it in an
41 appropriate system log, writes it to the system console, forwards it to a list
42 of users, or forwards it to \fBsyslogd\fR on another host over the network.
43 The logged message includes a message header and a message body. The message
44 header consists of a facility indicator, a severity level indicator, a
45 timestamp, a tag string, and optionally the process ID.
46 .sp
47 .LP
48 The message body is generated from the \fImessage\fR and following arguments in
49 the same manner as if these were arguments to \fBprintf\fR(3UCB), except that
50 occurrences of \fB%m\fR in the format string pointed to by the \fImessage\fR
51 argument are replaced by the error message string associated with the current
52 value of \fBerrno\fR. A trailing \fBNEWLINE\fR character is added if needed.
53 .sp
54 .LP
55 Symbolic constants for use as values of the \fIlogopt\fR, \fIfacility\fR,
56 \fIpriority\fR, and \fImaskpri\fR arguments are defined in the <\fBsyslog.h\fR>
57 header.
160 .RS 14n
161 Messages generated by random user processes. This is the default facility
162 identifier if none is specified.
163 .RE
164
165 .sp
166 .ne 2
167 .na
168 \fB\fBLOG_MAIL\fR\fR
169 .ad
170 .RS 14n
171 The mail system.
172 .RE
173
174 .sp
175 .ne 2
176 .na
177 \fB\fBLOG_DAEMON\fR\fR
178 .ad
179 .RS 14n
180 System daemons, such as \fBin.ftpd\fR(1M).
181 .RE
182
183 .sp
184 .ne 2
185 .na
186 \fB\fBLOG_AUTH\fR\fR
187 .ad
188 .RS 14n
189 The authentication / security / authorization system: \fBlogin\fR(1),
190 \fBsu\fR(1M), \fBgetty\fR(1M).
191 .RE
192
193 .sp
194 .ne 2
195 .na
196 \fB\fBLOG_LPR\fR\fR
197 .ad
198 .RS 14n
199 The line printer spooling system: \fBlpr\fR(1B), \fBlpc\fR(1B).
200 .RE
377 .sp
378 .LP
379 The \fBopenlog()\fR and \fBsyslog()\fR functions may allocate a file
380 descriptor. It is not necessary to call \fBopenlog()\fR prior to calling
381 \fBsyslog()\fR.
382 .sp
383 .LP
384 The \fBcloselog()\fR function closes any open file descriptors allocated by
385 previous calls to \fBopenlog()\fR or \fBsyslog()\fR.
386 .sp
387 .LP
388 The \fBsetlogmask()\fR function sets the log priority mask for the current
389 process to \fImaskpri\fR and returns the previous mask. If the \fImaskpri\fR
390 argument is 0, the current log mask is not modified. Calls by the current
391 process to \fBsyslog()\fR with a priority not set in \fImaskpri\fR are
392 rejected. The mask for an individual priority \fIpri\fR is calculated by the
393 macro \fBLOG_MASK(\fIpri\fR)\fR; the mask for all priorities up to and
394 including \fItoppri\fR is given by the macro \fBLOG_UPTO(\fItoppri\fR)\fR. The
395 default log mask allows all priorities to be logged.
396 .SH RETURN VALUES
397 .sp
398 .LP
399 The \fBsetlogmask()\fR function returns the previous log priority mask. The
400 \fBcloselog()\fR, \fBopenlog()\fR and \fBsyslog()\fR functions return no value.
401 .SH ERRORS
402 .sp
403 .LP
404 No errors are defined.
405 .SH EXAMPLES
406 .LP
407 \fBExample 1 \fRExample of \fBLOG_ALERT\fR message.
408 .sp
409 .LP
410 This call logs a message at priority \fBLOG_ALERT\fR:
411
412 .sp
413 .in +2
414 .nf
415 \fBsyslog(LOG_ALERT, "who: internal error 23")\fR;
416 .fi
417 .in -2
418 .sp
419
420 .sp
421 .LP
422 The \fBFTP\fR daemon \fBftpd\fR would make this call to \fBopenlog()\fR to
458 \fBsyslog(LOG_INFO, "Connection from host %d", CallingHost)\fR;
459 .fi
460 .in -2
461 .sp
462
463 .sp
464 .LP
465 A locally-written utility could use the following call to \fBsyslog()\fR to log
466 a message at priority \fBLOG_INFO\fR to be treated by \fBsyslogd\fR(1M) as
467 other messages to the facility \fBLOG_LOCAL2\fR are:
468
469 .sp
470 .in +2
471 .nf
472 \fBsyslog(LOG_INFO|LOG_LOCAL2, "error: %m")\fR;
473 .fi
474 .in -2
475 .sp
476
477 .SH ATTRIBUTES
478 .sp
479 .LP
480 See \fBattributes\fR(5) for descriptions of the following attributes:
481 .sp
482
483 .sp
484 .TS
485 box;
486 c | c
487 l | l .
488 ATTRIBUTE TYPE ATTRIBUTE VALUE
489 _
490 Interface Stability Committed
491 _
492 MT-Level Safe
493 _
494 Standard See \fBstandards\fR(5).
495 .TE
496
497 .SH SEE ALSO
498 .sp
499 .LP
500 \fBat\fR(1), \fBcrontab\fR(1), \fBlogger\fR(1), \fBlogin\fR(1), \fBlpc\fR(1B),
501 \fBlpr\fR(1B), \fBauditd\fR(1M), \fBcron\fR(1M), \fBgetty\fR(1M),
502 \fBin.ftpd\fR(1M), \fBsu\fR(1M), \fBsyslogd\fR(1M), \fBprintf\fR(3UCB),
503 \fBsyslog.conf\fR(4), \fBattributes\fR(5), \fBstandards\fR(5)
|
17
18 \fBvoid\fR \fBopenlog\fR(\fBconst char *\fR\fIident\fR, \fBint\fR \fIlogopt\fR, \fBint\fR \fIfacility\fR);
19 .fi
20
21 .LP
22 .nf
23 \fBvoid\fR \fBsyslog\fR(\fBint\fR \fIpriority\fR, \fBconst char *\fR\fImessage\fR, \fB\&.../*\fR \fIarguments\fR */);
24 .fi
25
26 .LP
27 .nf
28 \fBvoid\fR \fBcloselog\fR(\fBvoid\fR);
29 .fi
30
31 .LP
32 .nf
33 \fBint\fR \fBsetlogmask\fR(\fBint\fR \fImaskpri\fR);
34 .fi
35
36 .SH DESCRIPTION
37 .LP
38 The \fBsyslog()\fR function sends a message to \fBsyslogd\fR(1M), which,
39 depending on the configuration of \fB/etc/syslog.conf\fR, logs it in an
40 appropriate system log, writes it to the system console, forwards it to a list
41 of users, or forwards it to \fBsyslogd\fR on another host over the network.
42 The logged message includes a message header and a message body. The message
43 header consists of a facility indicator, a severity level indicator, a
44 timestamp, a tag string, and optionally the process ID.
45 .sp
46 .LP
47 The message body is generated from the \fImessage\fR and following arguments in
48 the same manner as if these were arguments to \fBprintf\fR(3UCB), except that
49 occurrences of \fB%m\fR in the format string pointed to by the \fImessage\fR
50 argument are replaced by the error message string associated with the current
51 value of \fBerrno\fR. A trailing \fBNEWLINE\fR character is added if needed.
52 .sp
53 .LP
54 Symbolic constants for use as values of the \fIlogopt\fR, \fIfacility\fR,
55 \fIpriority\fR, and \fImaskpri\fR arguments are defined in the <\fBsyslog.h\fR>
56 header.
159 .RS 14n
160 Messages generated by random user processes. This is the default facility
161 identifier if none is specified.
162 .RE
163
164 .sp
165 .ne 2
166 .na
167 \fB\fBLOG_MAIL\fR\fR
168 .ad
169 .RS 14n
170 The mail system.
171 .RE
172
173 .sp
174 .ne 2
175 .na
176 \fB\fBLOG_DAEMON\fR\fR
177 .ad
178 .RS 14n
179 System daemons.
180 .RE
181
182 .sp
183 .ne 2
184 .na
185 \fB\fBLOG_AUTH\fR\fR
186 .ad
187 .RS 14n
188 The authentication / security / authorization system: \fBlogin\fR(1),
189 \fBsu\fR(1M), \fBgetty\fR(1M).
190 .RE
191
192 .sp
193 .ne 2
194 .na
195 \fB\fBLOG_LPR\fR\fR
196 .ad
197 .RS 14n
198 The line printer spooling system: \fBlpr\fR(1B), \fBlpc\fR(1B).
199 .RE
376 .sp
377 .LP
378 The \fBopenlog()\fR and \fBsyslog()\fR functions may allocate a file
379 descriptor. It is not necessary to call \fBopenlog()\fR prior to calling
380 \fBsyslog()\fR.
381 .sp
382 .LP
383 The \fBcloselog()\fR function closes any open file descriptors allocated by
384 previous calls to \fBopenlog()\fR or \fBsyslog()\fR.
385 .sp
386 .LP
387 The \fBsetlogmask()\fR function sets the log priority mask for the current
388 process to \fImaskpri\fR and returns the previous mask. If the \fImaskpri\fR
389 argument is 0, the current log mask is not modified. Calls by the current
390 process to \fBsyslog()\fR with a priority not set in \fImaskpri\fR are
391 rejected. The mask for an individual priority \fIpri\fR is calculated by the
392 macro \fBLOG_MASK(\fIpri\fR)\fR; the mask for all priorities up to and
393 including \fItoppri\fR is given by the macro \fBLOG_UPTO(\fItoppri\fR)\fR. The
394 default log mask allows all priorities to be logged.
395 .SH RETURN VALUES
396 .LP
397 The \fBsetlogmask()\fR function returns the previous log priority mask. The
398 \fBcloselog()\fR, \fBopenlog()\fR and \fBsyslog()\fR functions return no value.
399 .SH ERRORS
400 .LP
401 No errors are defined.
402 .SH EXAMPLES
403 .LP
404 \fBExample 1 \fRExample of \fBLOG_ALERT\fR message.
405 .sp
406 .LP
407 This call logs a message at priority \fBLOG_ALERT\fR:
408
409 .sp
410 .in +2
411 .nf
412 \fBsyslog(LOG_ALERT, "who: internal error 23")\fR;
413 .fi
414 .in -2
415 .sp
416
417 .sp
418 .LP
419 The \fBFTP\fR daemon \fBftpd\fR would make this call to \fBopenlog()\fR to
455 \fBsyslog(LOG_INFO, "Connection from host %d", CallingHost)\fR;
456 .fi
457 .in -2
458 .sp
459
460 .sp
461 .LP
462 A locally-written utility could use the following call to \fBsyslog()\fR to log
463 a message at priority \fBLOG_INFO\fR to be treated by \fBsyslogd\fR(1M) as
464 other messages to the facility \fBLOG_LOCAL2\fR are:
465
466 .sp
467 .in +2
468 .nf
469 \fBsyslog(LOG_INFO|LOG_LOCAL2, "error: %m")\fR;
470 .fi
471 .in -2
472 .sp
473
474 .SH ATTRIBUTES
475 .LP
476 See \fBattributes\fR(5) for descriptions of the following attributes:
477 .sp
478
479 .sp
480 .TS
481 box;
482 c | c
483 l | l .
484 ATTRIBUTE TYPE ATTRIBUTE VALUE
485 _
486 Interface Stability Committed
487 _
488 MT-Level Safe
489 _
490 Standard See \fBstandards\fR(5).
491 .TE
492
493 .SH SEE ALSO
494 .LP
495 \fBat\fR(1), \fBcrontab\fR(1), \fBlogger\fR(1), \fBlogin\fR(1), \fBlpc\fR(1B),
496 \fBlpr\fR(1B), \fBauditd\fR(1M), \fBcron\fR(1M), \fBgetty\fR(1M),
497 \fBsu\fR(1M), \fBsyslogd\fR(1M), \fBprintf\fR(3UCB),
498 \fBsyslog.conf\fR(4), \fBattributes\fR(5), \fBstandards\fR(5)
|