]>
Commit | Line | Data |
---|---|---|
fea681da MK |
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 <mtk16@ext.canterbury.ac.nz> | |
26 | .\" Added description of vsyslog | |
27 | .\" Added descriptions of (SUSv3-specified) 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 <mtk16@ext.canterbury.ac.nz> | |
33 | .\" | |
34 | .TH SYSLOG 3 2002-01-03 "Linux" "Linux Programmer's Manual" | |
35 | .SH NAME | |
36 | closelog, openlog, syslog \- 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 | .BI "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 | .br | |
50 | .SH DESCRIPTION | |
51 | .B closelog() | |
52 | closes the descriptor being used to write to the system logger. The use of | |
53 | .B closelog() | |
54 | is optional. | |
55 | .sp | |
56 | .B openlog() | |
57 | opens a connection to the system logger for a program. The string pointed | |
58 | to by | |
59 | .I ident | |
60 | is prepended to every message, and is typically set to the program name. | |
61 | The | |
62 | .I option | |
63 | argument specifies flags which control the operation of | |
64 | .B openlog() | |
65 | and subsequent calls to | |
66 | .BR syslog() . | |
67 | The | |
68 | .I facility | |
69 | argument establishes a default to be used if | |
70 | none is specified in subsequent calls to | |
71 | .BR syslog() . | |
72 | Values for | |
73 | .I option | |
74 | and | |
75 | .I facility | |
76 | are given below. The use of | |
77 | .B openlog() | |
78 | is optional; it will automatically be called by | |
79 | .B syslog() | |
80 | if necessary, in which case | |
81 | .I ident | |
82 | will default to NULL. | |
83 | .sp | |
84 | .B syslog() | |
85 | generates a log message, which will be distributed by | |
86 | .BR syslogd (8). | |
87 | The | |
88 | .I priority | |
89 | argument is formed by ORing the | |
90 | .I facility | |
91 | and the | |
92 | .I level | |
93 | values (explained below). The remaining arguments | |
94 | are a | |
95 | .IR format , | |
96 | as in | |
97 | .BR printf (3) | |
98 | and any arguments required by the | |
99 | .IR format , | |
100 | except that the two character sequence %m will be replaced by | |
101 | the error message string | |
102 | .IR strerror ( errno ). | |
103 | A trailing newline is added when needed. | |
104 | ||
105 | The function | |
106 | .B vsyslog() | |
107 | performs the same task as | |
108 | .B syslog() | |
109 | with the difference that it takes a set of arguments which have | |
110 | been obtained using the | |
111 | .BR stdarg (3) | |
112 | variable argument list macros. | |
113 | .SH PARAMETERS | |
114 | This section lists the parameters used to set the values of | |
115 | .IR option , " facility" ", and " priority . | |
116 | .SS option | |
117 | The | |
118 | .I option | |
119 | argument to | |
120 | .B openlog() | |
121 | is an OR of any of these: | |
122 | .TP | |
123 | .B LOG_CONS | |
124 | Write directly to system console if there is an error while sending to | |
125 | system logger. | |
126 | .TP | |
127 | .B LOG_NDELAY | |
128 | Open the connection immediately (normally, the connection is opened when | |
129 | the first message is logged). | |
130 | .TP | |
131 | .B LOG_NOWAIT | |
132 | Don't wait for child processes that may have been created while logging | |
133 | the message. (The GNU C library does not create a child process, so this | |
134 | option has no effect on Linux.) | |
135 | .TP | |
136 | .B LOG_ODELAY | |
137 | The converse of | |
138 | .BR LOG_NDELAY ; | |
139 | opening of the connection is delayed until | |
140 | .B syslog() | |
141 | is called. (This is the default, and need not be specified.) | |
142 | .TP | |
143 | .B LOG_PERROR | |
144 | (Not in SUSv3.) Print to stderr as well. | |
145 | .TP | |
146 | .B LOG_PID | |
147 | Include PID with each message. | |
148 | .SS facility | |
149 | The | |
150 | .I facility | |
151 | argument is used to specify what type of program is logging the message. | |
152 | This lets the configuration file specify that messages from different | |
153 | facilities will be handled differently. | |
154 | .TP | |
155 | .B LOG_AUTH | |
156 | security/authorization messages (DEPRECATED Use | |
157 | .B LOG_AUTHPRIV | |
158 | instead) | |
159 | .TP | |
160 | .B LOG_AUTHPRIV | |
161 | security/authorization messages (private) | |
162 | .TP | |
163 | .B LOG_CRON | |
164 | clock daemon | |
165 | .RB ( cron " and " at ) | |
166 | .TP | |
167 | .B LOG_DAEMON | |
168 | system daemons without separate facility value | |
169 | .TP | |
170 | .B LOG_FTP | |
171 | ftp daemon | |
172 | .TP | |
173 | .B LOG_KERN | |
174 | kernel messages | |
175 | .TP | |
176 | .BR LOG_LOCAL0 " through " LOG_LOCAL7 | |
177 | reserved for local use | |
178 | .TP | |
179 | .B LOG_LPR | |
180 | line printer subsystem | |
181 | .TP | |
182 | .B LOG_MAIL | |
183 | mail subsystem | |
184 | .TP | |
185 | .B LOG_NEWS | |
186 | USENET news subsystem | |
187 | .TP | |
188 | .B LOG_SYSLOG | |
189 | messages generated internally by | |
190 | .B syslogd | |
191 | .TP | |
192 | .BR LOG_USER " (default)" | |
193 | generic user-level messages | |
194 | .TP | |
195 | .B LOG_UUCP | |
196 | UUCP subsystem | |
197 | ||
198 | .SS level | |
199 | This determines the importance of the message. The levels are, in order | |
200 | of decreasing importance: | |
201 | .TP | |
202 | .B LOG_EMERG | |
203 | system is unusable | |
204 | .TP | |
205 | .B LOG_ALERT | |
206 | action must be taken immediately | |
207 | .TP | |
208 | .B LOG_CRIT | |
209 | critical conditions | |
210 | .TP | |
211 | .B LOG_ERR | |
212 | error conditions | |
213 | .TP | |
214 | .B LOG_WARNING | |
215 | warning conditions | |
216 | .TP | |
217 | .B LOG_NOTICE | |
218 | normal, but significant, condition | |
219 | .TP | |
220 | .B LOG_INFO | |
221 | informational message | |
222 | .TP | |
223 | .B LOG_DEBUG | |
224 | debug-level message | |
225 | .LP | |
226 | The function | |
227 | .BR setlogmask (3) | |
228 | can be used to restrict logging to specified levels only. | |
229 | .SH "CONFORMING TO" | |
230 | The functions | |
231 | .BR openlog() , | |
232 | .BR closelog() , | |
233 | and | |
234 | .BR syslog() | |
235 | (but not | |
236 | .BR vsyslog() ) | |
237 | are specified in SUSv2 and POSIX 1003.1-2001. | |
238 | POSIX 1003.1-2001 specifies only the | |
239 | .B LOG_USER | |
240 | and | |
241 | .BR LOG_LOCAL* | |
242 | values for | |
243 | .IR facility . | |
244 | However, with the exception of | |
245 | .BR LOG_AUTHPRIV | |
246 | and | |
247 | .BR LOG_FTP , | |
248 | the other | |
249 | .I facility | |
250 | values appear on most Unix systems. | |
251 | The | |
252 | .B LOG_PERROR | |
253 | value for | |
254 | .I option | |
255 | is not specified by POSIX 1003.1-2001, but is available | |
256 | in most versions of Unix. | |
257 | .SH HISTORY | |
258 | A | |
259 | .B syslog | |
260 | function call appeared in BSD 4.2. | |
261 | BSD 4.3 documents | |
262 | .IR openlog (), | |
263 | .IR syslog (), | |
264 | .IR closelog (), | |
265 | and | |
266 | .IR setlogmask (). | |
267 | 4.3BSD-Reno also documents | |
268 | .IR vsyslog (). | |
269 | Of course early v* functions used the | |
270 | .I <varargs.h> | |
271 | mechanism, which is not compatible with | |
272 | .IR <stdarg.h> . | |
273 | .SH NOTES | |
274 | The parameter | |
275 | .I ident | |
276 | in the call of | |
277 | .B openlog() | |
278 | is probably stored as-is. Thus, if the string it points to | |
279 | is changed, | |
280 | .B syslog() | |
281 | may start prepending the changed string, and if the string | |
282 | it points to ceases to exist, the results are undefined. | |
283 | Most portable is to use a string constant. | |
284 | .LP | |
285 | Never pass a string with user-supplied data as a format, use | |
286 | .RS | |
287 | syslog(priority, "%s", string); | |
288 | .RE | |
289 | instead. | |
290 | .SH "SEE ALSO" | |
291 | .BR logger (1), | |
292 | .BR setlogmask (3), | |
293 | .BR syslog.conf (5), | |
294 | .BR syslogd (8) |