2 .\" Written Feb 1994 by Steve Greenland (stevegr@neosoft.com)
3 .\" and Copyright 2001, 2017 Michael Kerrisk <mtk.manpages@gmail.com>
5 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
7 .\" Updated 1999.12.19 by Karl M. Hegbloom <karlheg@debian.org>
9 .\" Updated 13 Oct 2001, Michael Kerrisk <mtk.manpages@gmail.com>
10 .\" Added description of vsyslog
11 .\" Added descriptions of LOG_ODELAY and LOG_NOWAIT
12 .\" Added brief description of facility and option arguments
13 .\" Added CONFORMING TO section
14 .\" 2001-10-13, aeb, minor changes
15 .\" Modified 13 Dec 2001, Martin Schulze <joey@infodrom.org>
16 .\" Modified 3 Jan 2002, Michael Kerrisk <mtk.manpages@gmail.com>
18 .TH syslog 3 (date) "Linux man-pages (unreleased)"
20 closelog, openlog, syslog, vsyslog \- send messages to the system logger
23 .RI ( libc ", " \-lc )
26 .B #include <syslog.h>
28 .BI "void openlog(const char *" ident ", int " option ", int " facility );
29 .BI "void syslog(int " priority ", const char *" format ", ...);"
30 .B "void closelog(void);"
32 .BI "void vsyslog(int " priority ", const char *" format ", va_list " ap );
36 Feature Test Macro Requirements for glibc (see
37 .BR feature_test_macros (7)):
44 glibc 2.19 and earlier:
50 opens a connection to the system logger for a program.
52 The string pointed to by
54 is prepended to every message, and is typically set to the program name.
57 is NULL, the program name is used.
58 (POSIX.1-2008 does not specify the behavior when
64 argument specifies flags which control the operation of
66 and subsequent calls to
70 argument establishes a default to be used if
71 none is specified in subsequent calls to
73 The values that may be specified for
81 is optional; it will automatically be called by
83 if necessary, in which case
87 .SS syslog() and vsyslog()
89 generates a log message, which will be distributed by
94 argument is formed by ORing together a
98 value (described below).
103 then the default value set by
105 is used, or, if there was no preceding
111 The remaining arguments are a
115 and any arguments required by the
117 except that the two-character sequence
120 the error message string
121 .IR strerror ( errno ).
122 The format string need not include a terminating newline character.
126 performs the same task as
128 with the difference that it takes a set of arguments which have
129 been obtained using the
131 variable argument list macros.
135 closes the file descriptor being used to write to the system logger.
140 .SS Values for \fIoption\fP
145 is a bit mask constructed by ORing together any of the following values:
148 Write directly to the system console if there is an error while sending to
152 Open the connection immediately (normally, the connection is opened when
153 the first message is logged).
154 This may be useful, for example, if a subsequent
156 would make the pathname used internally by the logging facility unreachable.
159 Don't wait for child processes that may have been created while logging
161 (The GNU C library does not create a child process, so this
162 option has no effect on Linux.)
167 opening of the connection is delayed until
170 (This is the default, and need not be specified.)
173 (Not in POSIX.1-2001 or POSIX.1-2008.)
174 Also log the message to
178 Include the caller's PID with each message.
180 .SS Values for \fIfacility\fP
183 argument is used to specify what type of program is logging the message.
184 This lets the configuration file specify that messages from different
185 facilities will be handled differently.
188 security/authorization messages
191 security/authorization messages (private)
195 .RB ( cron " and " at )
198 system daemons without separate facility value
204 kernel messages (these can't be generated from user processes)
205 .\" LOG_KERN has the value 0; if used as a facility, zero translates to:
206 .\" "use the default facility".
208 .BR LOG_LOCAL0 " through " LOG_LOCAL7
209 reserved for local use
212 line printer subsystem
218 USENET news subsystem
221 messages generated internally by
224 .BR LOG_USER " (default)"
225 generic user-level messages
230 .SS Values for \fIlevel\fP
231 This determines the importance of the message.
232 The levels are, in order of decreasing importance:
238 action must be taken immediately
250 normal, but significant, condition
253 informational message
260 can be used to restrict logging to specified levels only.
262 For an explanation of the terms used in this section, see
268 Interface Attribute Value
274 T} Thread safety MT-Safe
280 T} Thread safety MT-Safe env locale
296 4.2BSD, SUSv2, POSIX.1-2001.
301 4.3BSD, SUSv2, POSIX.1-2001.
304 .\" .BR setlogmask ().
308 .\" Of course early v* functions used the
310 .\" mechanism, which is not compatible with
313 POSIX.1-2001 specifies only the
319 However, with the exception of
325 values appear on most UNIX systems.
331 is not specified by POSIX.1-2001 or POSIX.1-2008, but is available
332 in most versions of UNIX.
338 is probably stored as-is.
339 Thus, if the string it points to
342 may start prepending the changed string, and if the string
343 it points to ceases to exist, the results are undefined.
344 Most portable is to use a string constant.
346 Never pass a string with user-supplied data as a format,
347 use the following instead:
351 syslog(priority, "%s", string);