1 .\" Written Feb 1994 by Steve Greenland (stevegr@neosoft.com)
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.
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.
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
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" Updated 1999.12.19 by Karl M. Hegbloom <karlheg@debian.org>
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>
34 .TH SYSLOG 3 2008-11-12 "Linux" "Linux Programmer's Manual"
36 closelog, openlog, syslog, vsyslog \- send messages to the system logger
38 .B #include <syslog.h>
40 .BI "void openlog(const char *" ident ", int " option ", int " facility );
42 .BI "void syslog(int " priority ", const char *" format ", ...);"
44 .B "void closelog(void);"
46 .B #include <stdarg.h>
48 .BI "void vsyslog(int " priority ", const char *" format ", va_list " ap );
51 Feature Test Macro Requirements for glibc (see
52 .BR feature_test_macros (7)):
59 closes the descriptor being used to write to the system logger.
65 opens a connection to the system logger for a program.
66 The string pointed to by
68 is prepended to every message, and is typically set to the program name.
71 argument specifies flags which control the operation of
73 and subsequent calls to
77 argument establishes a default to be used if
78 none is specified in subsequent calls to
87 is optional; it will automatically be called by
89 if necessary, in which case
94 generates a log message, which will be distributed by
98 argument is formed by ORing the
102 values (explained below).
103 The remaining arguments
108 and any arguments required by the
110 except that the two character sequence
113 the error message string
114 .IR strerror ( errno ).
115 A trailing newline may be added if needed.
119 performs the same task as
121 with the difference that it takes a set of arguments which have
122 been obtained using the
124 variable argument list macros.
126 The subsections below list the parameters used to set the values of
127 .IR option , " facility" ", and " priority .
133 is an OR of any of these:
136 Write directly to system console if there is an error while sending to
140 Open the connection immediately (normally, the connection is opened when
141 the first message is logged).
144 Don't wait for child processes that may have been created while logging
146 (The GNU C library does not create a child process, so this
147 option has no effect on Linux.)
152 opening of the connection is delayed until
155 (This is the default, and need not be specified.)
158 (Not in POSIX.1-2001.)
159 Print to \fIstderr\fP as well.
162 Include PID with each message.
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.
171 security/authorization messages (DEPRECATED Use
176 security/authorization messages (private)
180 .RB ( cron " and " at )
183 system daemons without separate facility value
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".
193 .BR LOG_LOCAL0 " through " LOG_LOCAL7
194 reserved for local use
197 line printer subsystem
203 USENET news subsystem
206 messages generated internally by
209 .BR LOG_USER " (default)"
210 generic user-level messages
215 This determines the importance of the message.
216 The levels are, in order of decreasing importance:
222 action must be taken immediately
234 normal, but significant, condition
237 informational message
244 can be used to restrict logging to specified levels only.
253 are specified in SUSv2 and POSIX.1-2001.
254 POSIX.1-2001 specifies only the
260 However, with the exception of
266 values appear on most Unix systems.
271 is not specified by POSIX.1-2001, but is available
272 in most versions of Unix.
276 .\" function call appeared in 4.2BSD.
282 .\" .BR setlogmask ().
283 .\" 4.3BSD-Reno also documents
285 .\" Of course early v* functions used the
287 .\" mechanism, which is not compatible with
294 is probably stored as-is.
295 Thus, if the string it points to
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.
302 Never pass a string with user-supplied data as a format,
303 use the following instead:
306 syslog(priority, "%s", string);