1 .\" Written Feb 1994 by Steve Greenland (stevegr@neosoft.com)
2 .\" and Copyright 2001, 2017 Michael Kerrisk <mtk.manpages@gmail.com>
4 .\" %%%LICENSE_START(VERBATIM)
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date. The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein. The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
26 .\" Updated 1999.12.19 by Karl M. Hegbloom <karlheg@debian.org>
28 .\" Updated 13 Oct 2001, Michael Kerrisk <mtk.manpages@gmail.com>
29 .\" Added description of vsyslog
30 .\" Added descriptions of LOG_ODELAY and LOG_NOWAIT
31 .\" Added brief description of facility and option arguments
32 .\" Added CONFORMING TO section
33 .\" 2001-10-13, aeb, minor changes
34 .\" Modified 13 Dec 2001, Martin Schulze <joey@infodrom.org>
35 .\" Modified 3 Jan 2002, Michael Kerrisk <mtk.manpages@gmail.com>
37 .TH SYSLOG 3 2017-09-15 "Linux" "Linux Programmer's Manual"
39 closelog, openlog, syslog, vsyslog \- send messages to the system logger
41 .B #include <syslog.h>
43 .BI "void openlog(const char *" ident ", int " option ", int " facility );
45 .BI "void syslog(int " priority ", const char *" format ", ...);"
47 .B "void closelog(void);"
49 .BI "void vsyslog(int " priority ", const char *" format ", va_list " ap );
52 Feature Test Macro Requirements for glibc (see
53 .BR feature_test_macros (7)):
59 Glibc 2.19 and earlier:
64 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 is NULL, the program name is used.
72 (POSIX.1-2008 does not specify the behavior when
78 argument specifies flags which control the operation of
80 and subsequent calls to
84 argument establishes a default to be used if
85 none is specified in subsequent calls to
87 The values that may be specified for
95 is optional; it will automatically be called by
97 if necessary, in which case
101 .SS syslog() and vsyslog()
103 generates a log message, which will be distributed by
108 argument is formed by ORing together a
112 value (described below).
117 then the default value set by
119 is used, or, if there was no preceding
125 The remaining arguments are a
129 and any arguments required by the
131 except that the two-character sequence
134 the error message string
135 .IR strerror ( errno ).
136 The format string need not include a terminating newline character.
140 performs the same task as
142 with the difference that it takes a set of arguments which have
143 been obtained using the
145 variable argument list macros.
149 closes the file descriptor being used to write to the system logger.
154 .SS Values for \fIoption\fP
159 is a bit mask constructed by ORing together any of the following values:
162 Write directly to the system console if there is an error while sending to
166 Open the connection immediately (normally, the connection is opened when
167 the first message is logged).
168 This may be useful, for example, if a subsequent
170 would make the pathname used internally by the logging facility unreachable.
173 Don't wait for child processes that may have been created while logging
175 (The GNU C library does not create a child process, so this
176 option has no effect on Linux.)
181 opening of the connection is delayed until
184 (This is the default, and need not be specified.)
187 (Not in POSIX.1-2001 or POSIX.1-2008.)
188 Also log the message to
192 Include the caller's PID with each message.
194 .SS Values for \fIfacility\fP
197 argument is used to specify what type of program is logging the message.
198 This lets the configuration file specify that messages from different
199 facilities will be handled differently.
202 security/authorization messages
205 security/authorization messages (private)
209 .RB ( cron " and " at )
212 system daemons without separate facility value
218 kernel messages (these can't be generated from user processes)
219 .\" LOG_KERN has the value 0; if used as a facility, zero translates to:
220 .\" "use the default facility".
222 .BR LOG_LOCAL0 " through " LOG_LOCAL7
223 reserved for local use
226 line printer subsystem
232 USENET news subsystem
235 messages generated internally by
238 .BR LOG_USER " (default)"
239 generic user-level messages
244 .SS Values for \fIlevel\fP
245 This determines the importance of the message.
246 The levels are, in order of decreasing importance:
252 action must be taken immediately
264 normal, but significant, condition
267 informational message
274 can be used to restrict logging to specified levels only.
276 For an explanation of the terms used in this section, see
282 Interface Attribute Value
286 T} Thread safety MT-Safe
290 T} Thread safety MT-Safe env locale
300 are specified in SUSv2, POSIX.1-2001, and POSIX.1-2008.
302 POSIX.1-2001 specifies only the
308 However, with the exception of
314 values appear on most UNIX systems.
320 is not specified by POSIX.1-2001 or POSIX.1-2008, but is available
321 in most versions of UNIX.
325 .\" function call appeared in 4.2BSD.
331 .\" .BR setlogmask ().
332 .\" 4.3BSD-Reno also documents
334 .\" Of course early v* functions used the
336 .\" mechanism, which is not compatible with
343 is probably stored as-is.
344 Thus, if the string it points to
347 may start prepending the changed string, and if the string
348 it points to ceases to exist, the results are undefined.
349 Most portable is to use a string constant.
351 Never pass a string with user-supplied data as a format,
352 use the following instead:
356 syslog(priority, "%s", string);