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
42 .B #include <syslog.h>
44 .BI "void openlog(const char *" ident ", int " option ", int " facility );
45 .BI "void syslog(int " priority ", const char *" format ", ...);"
46 .B "void closelog(void);"
48 .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)):
60 Glibc 2.19 and earlier:
66 opens a connection to the system logger for a program.
68 The string pointed to by
70 is prepended to every message, and is typically set to the program name.
73 is NULL, the program name is used.
74 (POSIX.1-2008 does not specify the behavior when
80 argument specifies flags which control the operation of
82 and subsequent calls to
86 argument establishes a default to be used if
87 none is specified in subsequent calls to
89 The values that may be specified for
97 is optional; it will automatically be called by
99 if necessary, in which case
101 will default to NULL.
103 .SS syslog() and vsyslog()
105 generates a log message, which will be distributed by
110 argument is formed by ORing together a
114 value (described below).
119 then the default value set by
121 is used, or, if there was no preceding
127 The remaining arguments are a
131 and any arguments required by the
133 except that the two-character sequence
136 the error message string
137 .IR strerror ( errno ).
138 The format string need not include a terminating newline character.
142 performs the same task as
144 with the difference that it takes a set of arguments which have
145 been obtained using the
147 variable argument list macros.
151 closes the file descriptor being used to write to the system logger.
156 .SS Values for \fIoption\fP
161 is a bit mask constructed by ORing together any of the following values:
164 Write directly to the system console if there is an error while sending to
168 Open the connection immediately (normally, the connection is opened when
169 the first message is logged).
170 This may be useful, for example, if a subsequent
172 would make the pathname used internally by the logging facility unreachable.
175 Don't wait for child processes that may have been created while logging
177 (The GNU C library does not create a child process, so this
178 option has no effect on Linux.)
183 opening of the connection is delayed until
186 (This is the default, and need not be specified.)
189 (Not in POSIX.1-2001 or POSIX.1-2008.)
190 Also log the message to
194 Include the caller's PID with each message.
196 .SS Values for \fIfacility\fP
199 argument is used to specify what type of program is logging the message.
200 This lets the configuration file specify that messages from different
201 facilities will be handled differently.
204 security/authorization messages
207 security/authorization messages (private)
211 .RB ( cron " and " at )
214 system daemons without separate facility value
220 kernel messages (these can't be generated from user processes)
221 .\" LOG_KERN has the value 0; if used as a facility, zero translates to:
222 .\" "use the default facility".
224 .BR LOG_LOCAL0 " through " LOG_LOCAL7
225 reserved for local use
228 line printer subsystem
234 USENET news subsystem
237 messages generated internally by
240 .BR LOG_USER " (default)"
241 generic user-level messages
246 .SS Values for \fIlevel\fP
247 This determines the importance of the message.
248 The levels are, in order of decreasing importance:
254 action must be taken immediately
266 normal, but significant, condition
269 informational message
276 can be used to restrict logging to specified levels only.
278 For an explanation of the terms used in this section, see
286 Interface Attribute Value
290 T} Thread safety MT-Safe
294 T} Thread safety MT-Safe env locale
307 are specified in SUSv2, POSIX.1-2001, and POSIX.1-2008.
309 POSIX.1-2001 specifies only the
315 However, with the exception of
321 values appear on most UNIX systems.
327 is not specified by POSIX.1-2001 or POSIX.1-2008, but is available
328 in most versions of UNIX.
332 .\" function call appeared in 4.2BSD.
338 .\" .BR setlogmask ().
339 .\" 4.3BSD-Reno also documents
341 .\" Of course early v* functions used the
343 .\" mechanism, which is not compatible with
350 is probably stored as-is.
351 Thus, if the string it points to
354 may start prepending the changed string, and if the string
355 it points to ceases to exist, the results are undefined.
356 Most portable is to use a string constant.
358 Never pass a string with user-supplied data as a format,
359 use the following instead:
363 syslog(priority, "%s", string);