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