1SYSLOG(3)                  Linux Programmer's Manual                 SYSLOG(3)
2
3
4

NAME

6       closelog, openlog, syslog, vsyslog - send messages to the system logger
7

SYNOPSIS

9       #include <syslog.h>
10
11       void openlog(const char *ident, int option, int facility);
12       void syslog(int priority, const char *format, ...);
13       void closelog(void);
14
15       #include <stdarg.h>
16
17       void vsyslog(int priority, const char *format, va_list ap);
18
19   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
20
21       vsyslog(): _BSD_SOURCE
22

DESCRIPTION

24       closelog() closes the descriptor being used to write to the system log‐
25       ger.  The use of closelog() is optional.
26
27       openlog() opens a connection to the system logger for a  program.   The
28       string  pointed to by ident is prepended to every message, and is typi‐
29       cally set to the program name.  The  option  argument  specifies  flags
30       which  control  the operation of openlog() and subsequent calls to sys‐
31       log().  The facility argument establishes a default to be used if  none
32       is  specified  in  subsequent calls to syslog().  Values for option and
33       facility are given below.  The use of openlog() is  optional;  it  will
34       automatically  be  called by syslog() if necessary, in which case ident
35       will default to NULL.
36
37       syslog() generates a log message, which will  be  distributed  by  sys‐
38       logd(8).  The priority argument is formed by ORing the facility and the
39       level values (explained below).  The remaining arguments are a  format,
40       as  in  printf(3) and any arguments required by the format, except that
41       the two character sequence %m will be replaced  by  the  error  message
42       string strerror(errno).  A trailing newline may be added if needed.
43
44       The function vsyslog() performs the same task as syslog() with the dif‐
45       ference that it takes a set of arguments which have been obtained using
46       the stdarg(3) variable argument list macros.
47
48       The  subsections  below  list  the parameters used to set the values of
49       option, facility, and priority.
50
51   option
52       The option argument to openlog() is an OR of any of these:
53
54       LOG_CONS       Write directly to system console if there  is  an  error
55                      while sending to system logger.
56
57       LOG_NDELAY     Open  the  connection immediately (normally, the connec‐
58                      tion is opened when the first message is logged).
59
60       LOG_NOWAIT     Don't wait for child processes that may have  been  cre‐
61                      ated while logging the message.  (The GNU C library does
62                      not create a child process, so this option has no effect
63                      on Linux.)
64
65       LOG_ODELAY     The converse of LOG_NDELAY; opening of the connection is
66                      delayed until syslog() is called.  (This is the default,
67                      and need not be specified.)
68
69       LOG_PERROR     (Not in POSIX.1-2001.)  Print to stderr as well.
70
71       LOG_PID        Include PID with each message.
72
73   facility
74       The  facility  argument is used to specify what type of program is log‐
75       ging the message.  This lets the configuration file specify  that  mes‐
76       sages from different facilities will be handled differently.
77
78       LOG_AUTH       security/authorization    messages    (DEPRECATED    Use
79                      LOG_AUTHPRIV instead)
80
81       LOG_AUTHPRIV   security/authorization messages (private)
82
83       LOG_CRON       clock daemon (cron and at)
84
85       LOG_DAEMON     system daemons without separate facility value
86
87       LOG_FTP        ftp daemon
88
89       LOG_KERN       kernel messages (these can't be generated from user pro‐
90                      cesses)
91
92       LOG_LOCAL0 through LOG_LOCAL7
93                      reserved for local use
94
95       LOG_LPR        line printer subsystem
96
97       LOG_MAIL       mail subsystem
98
99       LOG_NEWS       USENET news subsystem
100
101       LOG_SYSLOG     messages generated internally by syslogd(8)
102
103       LOG_USER (default)
104                      generic user-level messages
105
106       LOG_UUCP       UUCP subsystem
107
108   level
109       This  determines  the  importance  of  the message.  The levels are, in
110       order of decreasing importance:
111
112       LOG_EMERG      system is unusable
113
114       LOG_ALERT      action must be taken immediately
115
116       LOG_CRIT       critical conditions
117
118       LOG_ERR        error conditions
119
120       LOG_WARNING    warning conditions
121
122       LOG_NOTICE     normal, but significant, condition
123
124       LOG_INFO       informational message
125
126       LOG_DEBUG      debug-level message
127
128       The function setlogmask(3) can be used to restrict logging to specified
129       levels only.
130

CONFORMING TO

132       The  functions  openlog(), closelog(), and syslog() (but not vsyslog())
133       are specified in SUSv2 and POSIX.1-2001.  POSIX.1-2001  specifies  only
134       the  LOG_USER  and  LOG_LOCAL*  values for facility.  However, with the
135       exception of LOG_AUTHPRIV and LOG_FTP, the other facility values appear
136       on most Unix systems.  The LOG_PERROR value for option is not specified
137       by POSIX.1-2001, but is available in most versions of Unix.
138

NOTES

140       The argument ident in the call of openlog() is probably  stored  as-is.
141       Thus,  if  the  string  it  points  to  is  changed, syslog() may start
142       prepending the changed string, and if the string it points to ceases to
143       exist,  the  results  are  undefined.  Most portable is to use a string
144       constant.
145
146       Never pass a string with user-supplied data as a format, use  the  fol‐
147       lowing instead:
148
149           syslog(priority, "%s", string);
150

SEE ALSO

152       logger(1), setlogmask(3), syslog.conf(5), syslogd(8)
153

COLOPHON

155       This  page  is  part of release 3.22 of the Linux man-pages project.  A
156       description of the project, and information about reporting  bugs,  can
157       be found at http://www.kernel.org/doc/man-pages/.
158
159
160
161Linux                             2008-11-12                         SYSLOG(3)
Impressum