Remove advertising header from man pages.
[dragonfly.git] / lib / libc / gen / syslog.3
1 .\" Copyright (c) 1985, 1991, 1993
2 .\"     The Regents of the University of California.  All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\" 4. Neither the name of the University nor the names of its contributors
13 .\"    may be used to endorse or promote products derived from this software
14 .\"    without specific prior written permission.
15 .\"
16 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 .\" SUCH DAMAGE.
27 .\"
28 .\"     @(#)syslog.3    8.1 (Berkeley) 6/4/93
29 .\" $FreeBSD: src/lib/libc/gen/syslog.3,v 1.9.2.9 2001/12/14 18:33:51 ru Exp $
30 .\" $DragonFly: src/lib/libc/gen/syslog.3,v 1.2 2003/06/17 04:26:42 dillon Exp $
31 .\"
32 .Dd June 4, 1993
33 .Dt SYSLOG 3
34 .Os
35 .Sh NAME
36 .Nm syslog ,
37 .Nm vsyslog ,
38 .Nm openlog ,
39 .Nm closelog ,
40 .Nm setlogmask
41 .Nd control system log
42 .Sh LIBRARY
43 .Lb libc
44 .Sh SYNOPSIS
45 .In syslog.h
46 .In stdarg.h
47 .Ft void
48 .Fn syslog "int priority" "const char *message" "..."
49 .Ft void
50 .Fn vsyslog "int priority" "const char *message" "va_list args"
51 .Ft void
52 .Fn openlog "const char *ident" "int logopt" "int facility"
53 .Ft void
54 .Fn closelog void
55 .Ft int
56 .Fn setlogmask "int maskpri"
57 .Sh DESCRIPTION
58 The
59 .Fn syslog
60 function
61 writes
62 .Fa message
63 to the system message logger.
64 The message is then written to the system console, log files,
65 logged-in users, or forwarded to other machines as appropriate.
66 (See
67 .Xr syslogd 8 . )
68 .Pp
69 The message is identical to a
70 .Xr printf 3
71 format string, except that
72 .Ql %m
73 is replaced by the current error
74 message.
75 (As denoted by the global variable
76 .Va errno ;
77 see
78 .Xr strerror 3 . )
79 A trailing newline is added if none is present.
80 .Pp
81 The
82 .Fn vsyslog
83 function
84 is an alternate form in which the arguments have already been captured
85 using the variable-length argument facilities of
86 .Xr stdarg 3 .
87 .Pp
88 The message is tagged with
89 .Fa priority .
90 Priorities are encoded as a
91 .Fa facility
92 and a
93 .Em level .
94 The facility describes the part of the system
95 generating the message.
96 The level is selected from the following
97 .Em ordered
98 (high to low) list:
99 .Bl -tag -width LOG_AUTHPRIV
100 .It Dv LOG_EMERG
101 A panic condition.
102 This is normally broadcast to all users.
103 .It Dv LOG_ALERT
104 A condition that should be corrected immediately, such as a corrupted
105 system database.
106 .It Dv LOG_CRIT
107 Critical conditions, e.g., hard device errors.
108 .It Dv LOG_ERR
109 Errors.
110 .It Dv LOG_WARNING
111 Warning messages.
112 .It Dv LOG_NOTICE
113 Conditions that are not error conditions,
114 but should possibly be handled specially.
115 .It Dv LOG_INFO
116 Informational messages.
117 .It Dv LOG_DEBUG
118 Messages that contain information
119 normally of use only when debugging a program.
120 .El
121 .Pp
122 The
123 .Fn openlog
124 function
125 provides for more specialized processing of the messages sent
126 by
127 .Fn syslog
128 and
129 .Fn vsyslog .
130 The parameter
131 .Fa ident
132 is a string that will be prepended to every message.
133 The
134 .Fa logopt
135 argument
136 is a bit field specifying logging options, which is formed by
137 .Tn OR Ns 'ing
138 one or more of the following values:
139 .Bl -tag -width LOG_AUTHPRIV
140 .It Dv LOG_CONS
141 If
142 .Fn syslog
143 cannot pass the message to
144 .Xr syslogd 8
145 it will attempt to write the message to the console
146 .Pq Dq Pa /dev/console .
147 .It Dv LOG_NDELAY
148 Open the connection to
149 .Xr syslogd 8
150 immediately.
151 Normally the open is delayed until the first message is logged.
152 Useful for programs that need to manage the order in which file
153 descriptors are allocated.
154 .It Dv LOG_PERROR
155 Write the message to standard error output as well to the system log.
156 .It Dv LOG_PID
157 Log the process id with each message: useful for identifying
158 instantiations of daemons.
159 .El
160 .Pp
161 The
162 .Fa facility
163 parameter encodes a default facility to be assigned to all messages
164 that do not have an explicit facility encoded:
165 .Bl -tag -width LOG_AUTHPRIV
166 .It Dv LOG_AUTH
167 The authorization system:
168 .Xr login 1 ,
169 .Xr su 1 ,
170 .Xr getty 8 ,
171 etc.
172 .It Dv LOG_AUTHPRIV
173 The same as
174 .Dv LOG_AUTH ,
175 but logged to a file readable only by
176 selected individuals.
177 .It Dv LOG_CONSOLE
178 Messages written to
179 .Pa /dev/console
180 by the kernel console output driver.
181 .It Dv LOG_CRON
182 The cron daemon:
183 .Xr cron 8 .
184 .It Dv LOG_DAEMON
185 System daemons, such as
186 .Xr routed 8 ,
187 that are not provided for explicitly by other facilities.
188 .It Dv LOG_FTP
189 The file transfer protocol daemons:
190 .Xr ftpd 8 ,
191 .Xr tftpd 8 .
192 .It Dv LOG_KERN
193 Messages generated by the kernel.
194 These cannot be generated by any user processes.
195 .It Dv LOG_LPR
196 The line printer spooling system:
197 .Xr lpr 1 ,
198 .Xr lpc 8 ,
199 .Xr lpd 8 ,
200 etc.
201 .It Dv LOG_MAIL
202 The mail system.
203 .It Dv LOG_NEWS
204 The network news system.
205 .It Dv LOG_SECURITY
206 Security subsystems, such as
207 .Xr ipfw 4 .
208 .It Dv LOG_SYSLOG
209 Messages generated internally by
210 .Xr syslogd 8 .
211 .It Dv LOG_USER
212 Messages generated by random user processes.
213 This is the default facility identifier if none is specified.
214 .It Dv LOG_UUCP
215 The uucp system.
216 .It Dv LOG_LOCAL0
217 Reserved for local use.
218 Similarly for
219 .Dv LOG_LOCAL1
220 through
221 .Dv LOG_LOCAL7 .
222 .El
223 .Pp
224 The
225 .Fn closelog
226 function
227 can be used to close the log file.
228 .Pp
229 The
230 .Fn setlogmask
231 function
232 sets the log priority mask to
233 .Fa maskpri
234 and returns the previous mask.
235 Calls to
236 .Fn syslog
237 with a priority not set in
238 .Fa maskpri
239 are rejected.
240 The mask for an individual priority
241 .Fa pri
242 is calculated by the macro
243 .Fn LOG_MASK pri ;
244 the mask for all priorities up to and including
245 .Fa toppri
246 is given by the macro
247 .Fn LOG_UPTO toppri ; .
248 The default allows all priorities to be logged.
249 .Sh RETURN VALUES
250 The routines
251 .Fn closelog ,
252 .Fn openlog ,
253 .Fn syslog
254 and
255 .Fn vsyslog
256 return no value.
257 .Pp
258 The routine
259 .Fn setlogmask
260 always returns the previous log mask level.
261 .Sh EXAMPLES
262 .Bd -literal -offset indent -compact
263 syslog(LOG_ALERT, "who: internal error 23");
264
265 openlog("ftpd", LOG_PID | LOG_NDELAY, LOG_FTP);
266
267 setlogmask(LOG_UPTO(LOG_ERR));
268
269 syslog(LOG_INFO, "Connection from host %d", CallingHost);
270
271 syslog(LOG_INFO|LOG_LOCAL2, "foobar error: %m");
272 .Ed
273 .Sh SEE ALSO
274 .Xr logger 1 ,
275 .Xr syslogd 8
276 .Sh HISTORY
277 These
278 functions appeared in
279 .Bx 4.2 .