1 .\" Written Feb 1994 by Steve Greenland (stevegr@neosoft.com)
2 .\" and Copyright 2001, 2017 Michael Kerrisk <mtk.manpages@gmail.com>
4 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
6 .\" Updated 1999.12.19 by Karl M. Hegbloom <karlheg@debian.org>
8 .\" Updated 13 Oct 2001, Michael Kerrisk <mtk.manpages@gmail.com>
9 .\" Added description of vsyslog
10 .\" Added descriptions of LOG_ODELAY and LOG_NOWAIT
11 .\" Added brief description of facility and option arguments
12 .\" Added CONFORMING TO section
13 .\" 2001-10-13, aeb, minor changes
14 .\" Modified 13 Dec 2001, Martin Schulze <joey@infodrom.org>
15 .\" Modified 3 Jan 2002, Michael Kerrisk <mtk.manpages@gmail.com>
17 .TH SYSLOG 3 2021-03-22 "Linux" "Linux Programmer's Manual"
19 closelog, openlog, syslog, vsyslog \- send messages to the system logger
22 .RI ( libc ", " \-lc )
25 .B #include <syslog.h>
27 .BI "void openlog(const char *" ident ", int " option ", int " facility );
28 .BI "void syslog(int " priority ", const char *" format ", ...);"
29 .B "void closelog(void);"
31 .BI "void vsyslog(int " priority ", const char *" format ", va_list " ap );
35 Feature Test Macro Requirements for glibc (see
36 .BR feature_test_macros (7)):
43 Glibc 2.19 and earlier:
49 opens a connection to the system logger for a program.
51 The string pointed to by
53 is prepended to every message, and is typically set to the program name.
56 is NULL, the program name is used.
57 (POSIX.1-2008 does not specify the behavior when
63 argument specifies flags which control the operation of
65 and subsequent calls to
69 argument establishes a default to be used if
70 none is specified in subsequent calls to
72 The values that may be specified for
80 is optional; it will automatically be called by
82 if necessary, in which case
86 .SS syslog() and vsyslog()
88 generates a log message, which will be distributed by
93 argument is formed by ORing together a
97 value (described below).
102 then the default value set by
104 is used, or, if there was no preceding
110 The remaining arguments are a
114 and any arguments required by the
116 except that the two-character sequence
119 the error message string
120 .IR strerror ( errno ).
121 The format string need not include a terminating newline character.
125 performs the same task as
127 with the difference that it takes a set of arguments which have
128 been obtained using the
130 variable argument list macros.
134 closes the file descriptor being used to write to the system logger.
139 .SS Values for \fIoption\fP
144 is a bit mask constructed by ORing together any of the following values:
147 Write directly to the system console if there is an error while sending to
151 Open the connection immediately (normally, the connection is opened when
152 the first message is logged).
153 This may be useful, for example, if a subsequent
155 would make the pathname used internally by the logging facility unreachable.
158 Don't wait for child processes that may have been created while logging
160 (The GNU C library does not create a child process, so this
161 option has no effect on Linux.)
166 opening of the connection is delayed until
169 (This is the default, and need not be specified.)
172 (Not in POSIX.1-2001 or POSIX.1-2008.)
173 Also log the message to
177 Include the caller's PID with each message.
179 .SS Values for \fIfacility\fP
182 argument is used to specify what type of program is logging the message.
183 This lets the configuration file specify that messages from different
184 facilities will be handled differently.
187 security/authorization messages
190 security/authorization messages (private)
194 .RB ( cron " and " at )
197 system daemons without separate facility value
203 kernel messages (these can't be generated from user processes)
204 .\" LOG_KERN has the value 0; if used as a facility, zero translates to:
205 .\" "use the default facility".
207 .BR LOG_LOCAL0 " through " LOG_LOCAL7
208 reserved for local use
211 line printer subsystem
217 USENET news subsystem
220 messages generated internally by
223 .BR LOG_USER " (default)"
224 generic user-level messages
229 .SS Values for \fIlevel\fP
230 This determines the importance of the message.
231 The levels are, in order of decreasing importance:
237 action must be taken immediately
249 normal, but significant, condition
252 informational message
259 can be used to restrict logging to specified levels only.
261 For an explanation of the terms used in this section, see
269 Interface Attribute Value
273 T} Thread safety MT-Safe
277 T} Thread safety MT-Safe env locale
290 are specified in SUSv2, POSIX.1-2001, and POSIX.1-2008.
292 POSIX.1-2001 specifies only the
298 However, with the exception of
304 values appear on most UNIX systems.
310 is not specified by POSIX.1-2001 or POSIX.1-2008, but is available
311 in most versions of UNIX.
315 .\" function call appeared in 4.2BSD.
321 .\" .BR setlogmask ().
322 .\" 4.3BSD-Reno also documents
324 .\" Of course early v* functions used the
326 .\" mechanism, which is not compatible with
333 is probably stored as-is.
334 Thus, if the string it points to
337 may start prepending the changed string, and if the string
338 it points to ceases to exist, the results are undefined.
339 Most portable is to use a string constant.
341 Never pass a string with user-supplied data as a format,
342 use the following instead:
346 syslog(priority, "%s", string);