OSDN Git Service

(split) LDP man-pages の original/ を v3.29 に更新。
[linuxjm/LDP_man-pages.git] / original / man3 / syslog.3
1 .\" Written  Feb 1994 by Steve Greenland (stevegr@neosoft.com)
2 .\"
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
6 .\"
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
11 .\"
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein.  The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
18 .\" professionally.
19 .\"
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
22 .\"
23 .\" Updated 1999.12.19 by Karl M. Hegbloom <karlheg@debian.org>
24 .\"
25 .\" Updated 13 Oct 2001, Michael Kerrisk <mtk.manpages@gmail.com>
26 .\"     Added description of vsyslog
27 .\"     Added descriptions of LOG_ODELAY and LOG_NOWAIT
28 .\"     Added brief description of facility and option arguments
29 .\"     Added CONFORMING TO section
30 .\" 2001-10-13, aeb, minor changes
31 .\" Modified 13 Dec 2001, Martin Schulze <joey@infodrom.org>
32 .\" Modified 3 Jan 2002, Michael Kerrisk <mtk.manpages@gmail.com>
33 .\"
34 .TH SYSLOG 3 2008-11-12 "Linux" "Linux Programmer's Manual"
35 .SH NAME
36 closelog, openlog, syslog, vsyslog \- send messages to the system logger
37 .SH SYNOPSIS
38 .B #include <syslog.h>
39 .sp
40 .BI "void openlog(const char *" ident ", int " option ", int " facility );
41 .br
42 .BI "void syslog(int " priority ", const char *" format ", ...);"
43 .br
44 .B "void closelog(void);"
45 .sp
46 .B #include <stdarg.h>
47 .sp
48 .BI "void vsyslog(int " priority ", const char *" format ", va_list " ap );
49 .sp
50 .in -4n
51 Feature Test Macro Requirements for glibc (see
52 .BR feature_test_macros (7)):
53 .in
54 .sp
55 .BR vsyslog ():
56 _BSD_SOURCE
57 .SH DESCRIPTION
58 .BR closelog ()
59 closes the descriptor being used to write to the system logger.
60 The use of
61 .BR closelog ()
62 is optional.
63 .sp
64 .BR openlog ()
65 opens a connection to the system logger for a program.
66 The string pointed to by
67 .I ident
68 is prepended to every message, and is typically set to the program name.
69 The
70 .I option
71 argument specifies flags which control the operation of
72 .BR openlog ()
73 and subsequent calls to
74 .BR syslog ().
75 The
76 .I facility
77 argument establishes a default to be used if
78 none is specified in subsequent calls to
79 .BR syslog ().
80 Values for
81 .I option
82 and
83 .I facility
84 are given below.
85 The use of
86 .BR openlog ()
87 is optional; it will automatically be called by
88 .BR syslog ()
89 if necessary, in which case
90 .I ident
91 will default to NULL.
92 .sp
93 .BR syslog ()
94 generates a log message, which will be distributed by
95 .BR syslogd (8).
96 The
97 .I priority
98 argument is formed by ORing the
99 .I facility
100 and the
101 .I level
102 values (explained below).
103 The remaining arguments
104 are a
105 .IR format ,
106 as in
107 .BR printf (3)
108 and any arguments required by the
109 .IR format ,
110 except that the two character sequence
111 .B %m
112 will be replaced by
113 the error message string
114 .IR strerror ( errno ).
115 A trailing newline may be added if needed.
116
117 The function
118 .BR vsyslog ()
119 performs the same task as
120 .BR syslog ()
121 with the difference that it takes a set of arguments which have
122 been obtained using the
123 .BR stdarg (3)
124 variable argument list macros.
125
126 The subsections below list the parameters used to set the values of
127 .IR option , " facility" ", and " priority .
128 .SS option
129 The
130 .I option
131 argument to
132 .BR openlog ()
133 is an OR of any of these:
134 .TP 15
135 .B LOG_CONS
136 Write directly to system console if there is an error while sending to
137 system logger.
138 .TP
139 .B LOG_NDELAY
140 Open the connection immediately (normally, the connection is opened when
141 the first message is logged).
142 .TP
143 .B LOG_NOWAIT
144 Don't wait for child processes that may have been created while logging
145 the message.
146 (The GNU C library does not create a child process, so this
147 option has no effect on Linux.)
148 .TP
149 .B LOG_ODELAY
150 The converse of
151 .BR LOG_NDELAY ;
152 opening of the connection is delayed until
153 .BR syslog ()
154 is called.
155 (This is the default, and need not be specified.)
156 .TP
157 .B LOG_PERROR
158 (Not in POSIX.1-2001.)
159 Print to \fIstderr\fP as well.
160 .TP
161 .B LOG_PID
162 Include PID with each message.
163 .SS facility
164 The
165 .I facility
166 argument is used to specify what type of program is logging the message.
167 This lets the configuration file specify that messages from different
168 facilities will be handled differently.
169 .TP 15
170 .B LOG_AUTH
171 security/authorization messages (DEPRECATED Use
172 .B LOG_AUTHPRIV
173 instead)
174 .TP
175 .B LOG_AUTHPRIV
176 security/authorization messages (private)
177 .TP
178 .B LOG_CRON
179 clock daemon
180 .RB ( cron " and " at )
181 .TP
182 .B LOG_DAEMON
183 system daemons without separate facility value
184 .TP
185 .B LOG_FTP
186 ftp daemon
187 .TP
188 .B LOG_KERN
189 kernel messages (these can't be generated from user processes)
190 .\" LOG_KERN has the value 0; if used as a facility, zero translates to:
191 .\" "use the default facility".
192 .TP
193 .BR LOG_LOCAL0 " through " LOG_LOCAL7
194 reserved for local use
195 .TP
196 .B LOG_LPR
197 line printer subsystem
198 .TP
199 .B LOG_MAIL
200 mail subsystem
201 .TP
202 .B LOG_NEWS
203 USENET news subsystem
204 .TP
205 .B LOG_SYSLOG
206 messages generated internally by
207 .BR syslogd (8)
208 .TP
209 .BR LOG_USER " (default)"
210 generic user-level messages
211 .TP
212 .B LOG_UUCP
213 UUCP subsystem
214 .SS level
215 This determines the importance of the message.
216 The levels are, in order of decreasing importance:
217 .TP 15
218 .B LOG_EMERG
219 system is unusable
220 .TP
221 .B LOG_ALERT
222 action must be taken immediately
223 .TP
224 .B LOG_CRIT
225 critical conditions
226 .TP
227 .B LOG_ERR
228 error conditions
229 .TP
230 .B LOG_WARNING
231 warning conditions
232 .TP
233 .B LOG_NOTICE
234 normal, but significant, condition
235 .TP
236 .B LOG_INFO
237 informational message
238 .TP
239 .B LOG_DEBUG
240 debug-level message
241 .LP
242 The function
243 .BR setlogmask (3)
244 can be used to restrict logging to specified levels only.
245 .SH "CONFORMING TO"
246 The functions
247 .BR openlog (),
248 .BR closelog (),
249 and
250 .BR syslog ()
251 (but not
252 .BR vsyslog ())
253 are specified in SUSv2 and POSIX.1-2001.
254 POSIX.1-2001 specifies only the
255 .B LOG_USER
256 and
257 .B LOG_LOCAL*
258 values for
259 .IR facility .
260 However, with the exception of
261 .B LOG_AUTHPRIV
262 and
263 .BR LOG_FTP ,
264 the other
265 .I facility
266 values appear on most UNIX systems.
267 The
268 .B LOG_PERROR
269 value for
270 .I option
271 is not specified by POSIX.1-2001, but is available
272 in most versions of UNIX.
273 .\" .SH HISTORY
274 .\" A
275 .\" .BR syslog ()
276 .\" function call appeared in 4.2BSD.
277 .\" 4.3BSD documents
278 .\" .BR openlog (),
279 .\" .BR syslog (),
280 .\" .BR closelog (),
281 .\" and
282 .\" .BR setlogmask ().
283 .\" 4.3BSD-Reno also documents
284 .\" .BR vsyslog ().
285 .\" Of course early v* functions used the
286 .\" .I <varargs.h>
287 .\" mechanism, which is not compatible with
288 .\" .IR <stdarg.h> .
289 .SH NOTES
290 The argument
291 .I ident
292 in the call of
293 .BR openlog ()
294 is probably stored as-is.
295 Thus, if the string it points to
296 is changed,
297 .BR syslog ()
298 may start prepending the changed string, and if the string
299 it points to ceases to exist, the results are undefined.
300 Most portable is to use a string constant.
301 .LP
302 Never pass a string with user-supplied data as a format,
303 use the following instead:
304 .nf
305
306     syslog(priority, "%s", string);
307 .fi
308 .SH "SEE ALSO"
309 .BR logger (1),
310 .BR setlogmask (3),
311 .BR syslog.conf (5),
312 .BR syslogd (8)