Print this page
4358 syslog(3c) man page refers non-existent printf(3ucb)
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/man/man3c/syslog.3c
+++ new/usr/src/man/man3c/syslog.3c
1 1 '\" te
2 2 .\" Copyright (c) 2009, Sun Microsystems, Inc. All Rights Reserved.
3 3 .\" Copyright (c) 1983 Regents of the University of California. All rights reserved. The Berkeley software License Agreement specifies the terms and conditions for redistribution.
4 4 .\" Portions Copyright (c) 1992, X/Open Company Limited All Rights Reserved
5 5 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at http://www.opengroup.org/bookstore/.
6 6 .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text
7 7 .\" are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical
8 8 .\" and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
9 9 .\" This notice shall appear on any product containing this material.
10 10 .TH SYSLOG 3C "Mar 16, 2009"
11 11 .SH NAME
12 12 syslog, openlog, closelog, setlogmask \- control system log
13 13 .SH SYNOPSIS
14 14 .LP
15 15 .nf
16 16 #include <syslog.h>
17 17
18 18 \fBvoid\fR \fBopenlog\fR(\fBconst char *\fR\fIident\fR, \fBint\fR \fIlogopt\fR, \fBint\fR \fIfacility\fR);
19 19 .fi
20 20
21 21 .LP
22 22 .nf
23 23 \fBvoid\fR \fBsyslog\fR(\fBint\fR \fIpriority\fR, \fBconst char *\fR\fImessage\fR, \fB\&.../*\fR \fIarguments\fR */);
24 24 .fi
25 25
26 26 .LP
27 27 .nf
28 28 \fBvoid\fR \fBcloselog\fR(\fBvoid\fR);
29 29 .fi
30 30
31 31 .LP
32 32 .nf
33 33 \fBint\fR \fBsetlogmask\fR(\fBint\fR \fImaskpri\fR);
34 34 .fi
35 35
36 36 .SH DESCRIPTION
37 37 .sp
38 38 .LP
↓ open down ↓ |
38 lines elided |
↑ open up ↑ |
39 39 The \fBsyslog()\fR function sends a message to \fBsyslogd\fR(1M), which,
40 40 depending on the configuration of \fB/etc/syslog.conf\fR, logs it in an
41 41 appropriate system log, writes it to the system console, forwards it to a list
42 42 of users, or forwards it to \fBsyslogd\fR on another host over the network.
43 43 The logged message includes a message header and a message body. The message
44 44 header consists of a facility indicator, a severity level indicator, a
45 45 timestamp, a tag string, and optionally the process ID.
46 46 .sp
47 47 .LP
48 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
49 +the same manner as if these were arguments to \fBprintf\fR(3C), except that
50 50 occurrences of \fB%m\fR in the format string pointed to by the \fImessage\fR
51 51 argument are replaced by the error message string associated with the current
52 52 value of \fBerrno\fR. A trailing \fBNEWLINE\fR character is added if needed.
53 53 .sp
54 54 .LP
55 55 Symbolic constants for use as values of the \fIlogopt\fR, \fIfacility\fR,
56 56 \fIpriority\fR, and \fImaskpri\fR arguments are defined in the <\fBsyslog.h\fR>
57 57 header.
58 58 .sp
59 59 .LP
60 60 Values of the \fIpriority\fR argument are formed by ORing together a
61 61 \fIseverity level\fR value and an optional \fIfacility\fR value. If no
62 62 facility value is specified, the current default facility value is used.
63 63 .sp
64 64 .LP
65 65 Possible values of severity level include, in decreasing order:
66 66 .sp
67 67 .ne 2
68 68 .na
69 69 \fB\fBLOG_EMERG\fR\fR
70 70 .ad
71 71 .RS 15n
72 72 A panic condition. This is normally broadcast to all users.
73 73 .RE
74 74
75 75 .sp
76 76 .ne 2
77 77 .na
78 78 \fB\fBLOG_ALERT\fR\fR
79 79 .ad
80 80 .RS 15n
81 81 A condition that should be corrected immediately, such as a corrupted system
82 82 database.
83 83 .RE
84 84
85 85 .sp
86 86 .ne 2
87 87 .na
88 88 \fB\fBLOG_CRIT\fR\fR
89 89 .ad
90 90 .RS 15n
91 91 Critical conditions, such as hard device errors.
92 92 .RE
93 93
94 94 .sp
95 95 .ne 2
96 96 .na
97 97 \fB\fBLOG_ERR\fR\fR
98 98 .ad
99 99 .RS 15n
100 100 Errors.
101 101 .RE
102 102
103 103 .sp
104 104 .ne 2
105 105 .na
106 106 \fB\fBLOG_WARNING\fR\fR
107 107 .ad
108 108 .RS 15n
109 109 Warning messages.
110 110 .RE
111 111
112 112 .sp
113 113 .ne 2
114 114 .na
115 115 \fB\fBLOG_NOTICE\fR\fR
116 116 .ad
117 117 .RS 15n
118 118 Conditions that are not error conditions, but that may require special
119 119 handling.
120 120 .RE
121 121
122 122 .sp
123 123 .ne 2
124 124 .na
125 125 \fB\fBLOG_INFO\fR\fR
126 126 .ad
127 127 .RS 15n
128 128 Informational messages.
129 129 .RE
130 130
131 131 .sp
132 132 .ne 2
133 133 .na
134 134 \fB\fBLOG_DEBUG\fR\fR
135 135 .ad
136 136 .RS 15n
137 137 Messages that contain information normally of use only when debugging a
138 138 program.
139 139 .RE
140 140
141 141 .sp
142 142 .LP
143 143 The facility indicates the application or system component generating the
144 144 message. Possible facility values include:
145 145 .sp
146 146 .ne 2
147 147 .na
148 148 \fB\fBLOG_KERN\fR\fR
149 149 .ad
150 150 .RS 14n
151 151 Messages generated by the kernel. These cannot be generated by any user
152 152 processes.
153 153 .RE
154 154
155 155 .sp
156 156 .ne 2
157 157 .na
158 158 \fB\fBLOG_USER\fR\fR
159 159 .ad
160 160 .RS 14n
161 161 Messages generated by random user processes. This is the default facility
162 162 identifier if none is specified.
163 163 .RE
164 164
165 165 .sp
166 166 .ne 2
167 167 .na
168 168 \fB\fBLOG_MAIL\fR\fR
169 169 .ad
170 170 .RS 14n
171 171 The mail system.
172 172 .RE
173 173
174 174 .sp
175 175 .ne 2
176 176 .na
177 177 \fB\fBLOG_DAEMON\fR\fR
178 178 .ad
179 179 .RS 14n
180 180 System daemons, such as \fBin.ftpd\fR(1M).
181 181 .RE
182 182
183 183 .sp
184 184 .ne 2
185 185 .na
186 186 \fB\fBLOG_AUTH\fR\fR
187 187 .ad
188 188 .RS 14n
189 189 The authentication / security / authorization system: \fBlogin\fR(1),
190 190 \fBsu\fR(1M), \fBgetty\fR(1M).
191 191 .RE
192 192
193 193 .sp
194 194 .ne 2
195 195 .na
196 196 \fB\fBLOG_LPR\fR\fR
197 197 .ad
198 198 .RS 14n
199 199 The line printer spooling system: \fBlpr\fR(1B), \fBlpc\fR(1B).
200 200 .RE
201 201
202 202 .sp
203 203 .ne 2
204 204 .na
205 205 \fB\fBLOG_NEWS\fR\fR
206 206 .ad
207 207 .RS 14n
208 208 Designated for the \fBUSENET\fR network news system.
209 209 .RE
210 210
211 211 .sp
212 212 .ne 2
213 213 .na
214 214 \fB\fBLOG_UUCP\fR\fR
215 215 .ad
216 216 .RS 14n
217 217 Designated for the \fBUUCP\fR system; it does not currently use \fBsyslog()\fR.
218 218 .RE
219 219
220 220 .sp
221 221 .ne 2
222 222 .na
223 223 \fB\fBLOG_CRON\fR\fR
224 224 .ad
225 225 .RS 14n
226 226 The \fBcron\fR/\fBat\fR facility; \fBcrontab\fR(1), \fBat\fR(1),
227 227 \fBcron\fR(1M).
228 228 .RE
229 229
230 230 .sp
231 231 .ne 2
232 232 .na
233 233 \fB\fBLOG_AUDIT\fR\fR
234 234 .ad
235 235 .RS 14n
236 236 The audit facility, for example, \fBauditd\fR(1M).
237 237 .RE
238 238
239 239 .sp
240 240 .ne 2
241 241 .na
242 242 \fB\fBLOG_LOCAL0\fR\fR
243 243 .ad
244 244 .RS 14n
245 245 Designated for local use.
246 246 .RE
247 247
248 248 .sp
249 249 .ne 2
250 250 .na
251 251 \fB\fBLOG_LOCAL1\fR\fR
252 252 .ad
253 253 .RS 14n
254 254 Designated for local use.
255 255 .RE
256 256
257 257 .sp
258 258 .ne 2
259 259 .na
260 260 \fB\fBLOG_LOCAL2\fR\fR
261 261 .ad
262 262 .RS 14n
263 263 Designated for local use.
264 264 .RE
265 265
266 266 .sp
267 267 .ne 2
268 268 .na
269 269 \fB\fBLOG_LOCAL3\fR\fR
270 270 .ad
271 271 .RS 14n
272 272 Designated for local use.
273 273 .RE
274 274
275 275 .sp
276 276 .ne 2
277 277 .na
278 278 \fB\fBLOG_LOCAL4\fR\fR
279 279 .ad
280 280 .RS 14n
281 281 Designated for local use.
282 282 .RE
283 283
284 284 .sp
285 285 .ne 2
286 286 .na
287 287 \fB\fBLOG_LOCAL5\fR\fR
288 288 .ad
289 289 .RS 14n
290 290 Designated for local use.
291 291 .RE
292 292
293 293 .sp
294 294 .ne 2
295 295 .na
296 296 \fB\fBLOG_LOCAL6\fR\fR
297 297 .ad
298 298 .RS 14n
299 299 Designated for local use.
300 300 .RE
301 301
302 302 .sp
303 303 .ne 2
304 304 .na
305 305 \fB\fBLOG_LOCAL7\fR\fR
306 306 .ad
307 307 .RS 14n
308 308 Designated for local use.
309 309 .RE
310 310
311 311 .sp
312 312 .LP
313 313 The \fBopenlog()\fR function sets process attributes that affect subsequent
314 314 calls to \fBsyslog()\fR. The \fIident\fR argument is a string that is prepended
315 315 to every message. The \fBopenlog()\fR function uses the passed-in \fIident\fR
316 316 argument directly, rather than making a private copy of it. The \fIlogopt\fR
317 317 argument indicates logging options. Values for \fIlogopt\fR are constructed by
318 318 a bitwise-inclusive OR of zero or more of the following:
319 319 .sp
320 320 .ne 2
321 321 .na
322 322 \fB\fBLOG_PID\fR\fR
323 323 .ad
324 324 .RS 14n
325 325 Log the process \fBID\fR with each message. This is useful for identifying
326 326 specific daemon processes (for daemons that fork).
327 327 .RE
328 328
329 329 .sp
330 330 .ne 2
331 331 .na
332 332 \fB\fBLOG_CONS\fR\fR
333 333 .ad
334 334 .RS 14n
335 335 Write messages to the system console if they cannot be sent to
336 336 \fBsyslogd\fR(1M). This option is safe to use in daemon processes that have no
337 337 controlling terminal, since \fBsyslog()\fR forks before opening the console.
338 338 .RE
339 339
340 340 .sp
341 341 .ne 2
342 342 .na
343 343 \fB\fBLOG_NDELAY\fR\fR
344 344 .ad
345 345 .RS 14n
346 346 Open the connection to \fBsyslogd\fR(1M) immediately. Normally the open is
347 347 delayed until the first message is logged. This is useful for programs that
348 348 need to manage the order in which file descriptors are allocated.
349 349 .RE
350 350
351 351 .sp
352 352 .ne 2
353 353 .na
354 354 \fB\fBLOG_ODELAY\fR\fR
355 355 .ad
356 356 .RS 14n
357 357 Delay open until \fBsyslog()\fR is called.
358 358 .RE
359 359
360 360 .sp
361 361 .ne 2
362 362 .na
363 363 \fB\fBLOG_NOWAIT\fR\fR
364 364 .ad
365 365 .RS 14n
366 366 Do not wait for child processes that have been forked to log messages onto the
367 367 console. This option should be used by processes that enable notification of
368 368 child termination using \fBSIGCHLD\fR, since \fBsyslog()\fR may otherwise block
369 369 waiting for a child whose exit status has already been collected.
370 370 .RE
371 371
372 372 .sp
373 373 .LP
374 374 The \fIfacility\fR argument encodes a default facility to be assigned to all
375 375 messages that do not have an explicit facility already encoded. The initial
376 376 default facility is \fBLOG_USER\fR.
377 377 .sp
378 378 .LP
379 379 The \fBopenlog()\fR and \fBsyslog()\fR functions may allocate a file
380 380 descriptor. It is not necessary to call \fBopenlog()\fR prior to calling
381 381 \fBsyslog()\fR.
382 382 .sp
383 383 .LP
384 384 The \fBcloselog()\fR function closes any open file descriptors allocated by
385 385 previous calls to \fBopenlog()\fR or \fBsyslog()\fR.
386 386 .sp
387 387 .LP
388 388 The \fBsetlogmask()\fR function sets the log priority mask for the current
389 389 process to \fImaskpri\fR and returns the previous mask. If the \fImaskpri\fR
390 390 argument is 0, the current log mask is not modified. Calls by the current
391 391 process to \fBsyslog()\fR with a priority not set in \fImaskpri\fR are
392 392 rejected. The mask for an individual priority \fIpri\fR is calculated by the
393 393 macro \fBLOG_MASK(\fIpri\fR)\fR; the mask for all priorities up to and
394 394 including \fItoppri\fR is given by the macro \fBLOG_UPTO(\fItoppri\fR)\fR. The
395 395 default log mask allows all priorities to be logged.
396 396 .SH RETURN VALUES
397 397 .sp
398 398 .LP
399 399 The \fBsetlogmask()\fR function returns the previous log priority mask. The
400 400 \fBcloselog()\fR, \fBopenlog()\fR and \fBsyslog()\fR functions return no value.
401 401 .SH ERRORS
402 402 .sp
403 403 .LP
404 404 No errors are defined.
405 405 .SH EXAMPLES
406 406 .LP
407 407 \fBExample 1 \fRExample of \fBLOG_ALERT\fR message.
408 408 .sp
409 409 .LP
410 410 This call logs a message at priority \fBLOG_ALERT\fR:
411 411
412 412 .sp
413 413 .in +2
414 414 .nf
415 415 \fBsyslog(LOG_ALERT, "who: internal error 23")\fR;
416 416 .fi
417 417 .in -2
418 418 .sp
419 419
420 420 .sp
421 421 .LP
422 422 The \fBFTP\fR daemon \fBftpd\fR would make this call to \fBopenlog()\fR to
423 423 indicate that all messages it logs should have an identifying string of
424 424 \fBftpd\fR, should be treated by \fBsyslogd\fR(1M) as other messages from
425 425 system daemons are, should include the process \fBID\fR of the process logging
426 426 the message:
427 427
428 428 .sp
429 429 .in +2
430 430 .nf
431 431 \fBopenlog("ftpd", LOG_PID, LOG_DAEMON)\fR;
432 432 .fi
433 433 .in -2
434 434 .sp
435 435
436 436 .sp
437 437 .LP
438 438 Then it would make the following call to \fBsetlogmask()\fR to indicate that
439 439 messages at priorities from \fBLOG_EMERG\fR through \fBLOG_ERR\fR should be
440 440 logged, but that no messages at any other priority should be logged:
441 441
442 442 .sp
443 443 .in +2
444 444 .nf
445 445 \fBsetlogmask(LOG_UPTO(LOG_ERR))\fR;
446 446 .fi
447 447 .in -2
448 448 .sp
449 449
450 450 .sp
451 451 .LP
452 452 Then, to log a message at priority \fBLOG_INFO\fR, it would make the following
453 453 call to \fBsyslog\fR:
454 454
455 455 .sp
456 456 .in +2
457 457 .nf
458 458 \fBsyslog(LOG_INFO, "Connection from host %d", CallingHost)\fR;
459 459 .fi
460 460 .in -2
461 461 .sp
462 462
463 463 .sp
464 464 .LP
465 465 A locally-written utility could use the following call to \fBsyslog()\fR to log
466 466 a message at priority \fBLOG_INFO\fR to be treated by \fBsyslogd\fR(1M) as
467 467 other messages to the facility \fBLOG_LOCAL2\fR are:
468 468
469 469 .sp
470 470 .in +2
471 471 .nf
472 472 \fBsyslog(LOG_INFO|LOG_LOCAL2, "error: %m")\fR;
473 473 .fi
474 474 .in -2
475 475 .sp
476 476
477 477 .SH ATTRIBUTES
478 478 .sp
479 479 .LP
480 480 See \fBattributes\fR(5) for descriptions of the following attributes:
481 481 .sp
482 482
483 483 .sp
484 484 .TS
485 485 box;
486 486 c | c
487 487 l | l .
488 488 ATTRIBUTE TYPE ATTRIBUTE VALUE
489 489 _
490 490 Interface Stability Committed
491 491 _
492 492 MT-Level Safe
493 493 _
494 494 Standard See \fBstandards\fR(5).
495 495 .TE
496 496
497 497 .SH SEE ALSO
498 498 .sp
499 499 .LP
500 500 \fBat\fR(1), \fBcrontab\fR(1), \fBlogger\fR(1), \fBlogin\fR(1), \fBlpc\fR(1B),
501 501 \fBlpr\fR(1B), \fBauditd\fR(1M), \fBcron\fR(1M), \fBgetty\fR(1M),
502 502 \fBin.ftpd\fR(1M), \fBsu\fR(1M), \fBsyslogd\fR(1M), \fBprintf\fR(3UCB),
503 503 \fBsyslog.conf\fR(4), \fBattributes\fR(5), \fBstandards\fR(5)
↓ open down ↓ |
444 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX