Commit | Line | Data |
---|---|---|
5442f39e KB |
1 | .\" Copyright (c) 1985 The Regents of the University of California. |
2 | .\" All rights reserved. | |
609b3d57 | 3 | .\" |
91cff1e1 | 4 | .\" %sccs.include.redist.man% |
5442f39e | 5 | .\" |
51dad0a9 | 6 | .\" @(#)syslog.3 6.14 (Berkeley) %G% |
609b3d57 | 7 | .\" |
ed6316b8 | 8 | .TH SYSLOG 3 "" |
609b3d57 KM |
9 | .UC 5 |
10 | .SH NAME | |
51dad0a9 | 11 | syslog, vsyslog, openlog, closelog, setlogmask \- control system log |
609b3d57 | 12 | .SH SYNOPSIS |
51dad0a9 KB |
13 | .nf |
14 | .ft B | |
15 | #include <syslog.h> | |
16 | syslog(int priority, char *message, [, arg ] ... ); | |
17 | ||
18 | include <varargs.h> | |
19 | vsyslog(int priority, char *message, va_list args); | |
20 | ||
21 | openlog(char *ident, int logopt, int facility); | |
22 | ||
23 | closelog(void); | |
24 | ||
25 | setlogmask(int maskpri); | |
26 | .ft R | |
27 | .fi | |
609b3d57 KM |
28 | .SH DESCRIPTION |
29 | .I Syslog | |
51dad0a9 | 30 | writes |
609b3d57 | 31 | .I message |
51dad0a9 KB |
32 | to the system message logger. |
33 | The message will then be written to the system console, log files, | |
34 | logged-in users, or forwarded to other machines as appropriate (see | |
35 | .IR syslogd (8)). | |
36 | .PP | |
37 | The message is identical to a | |
609b3d57 | 38 | .IR printf (3) |
51dad0a9 KB |
39 | format string, except that ``%m'' is replaced by the current error |
40 | message (as denoted by | |
41 | .IR errno ; | |
42 | see | |
43 | .IR strerror (3)). | |
44 | A trailing newline is added if none is present. | |
bbb3b705 | 45 | .PP |
51dad0a9 KB |
46 | .I Vsyslog |
47 | is an alternate form in which the arguments have already been captured | |
48 | using the variable-length argument facilities of | |
49 | .IR varargs (3). | |
be78fd26 | 50 | .PP |
51dad0a9 KB |
51 | The message is tagged with |
52 | .IR priority . | |
be78fd26 EA |
53 | Priorities are encoded as a |
54 | .I facility | |
55 | and a | |
56 | .IR level . | |
57 | The facility describes the part of the system | |
58 | generating the message. | |
51dad0a9 KB |
59 | The level is selected from the following |
60 | .B ordered | |
61 | (high to low) list: | |
3f4b96b5 KB |
62 | .TP |
63 | LOG_EMERG | |
64 | A panic condition. | |
65 | This is normally broadcast to all users. | |
66 | .TP | |
51dad0a9 KB |
67 | LOG_ALERT |
68 | A condition that should be corrected immediately, such as a corrupted | |
69 | system database. | |
70 | .TP | |
71 | LOG_CRIT | |
72 | Critical conditions, e.g., hard device errors. | |
73 | .TP | |
c262cc40 | 74 | LOG_ERR |
be78fd26 | 75 | Errors. |
c262cc40 | 76 | .TP |
51dad0a9 KB |
77 | LOG_WARNING |
78 | Warning messages. | |
c262cc40 KB |
79 | .TP |
80 | LOG_NOTICE | |
be78fd26 EA |
81 | Conditions that are not error conditions, |
82 | but should possibly be handled specially. | |
c262cc40 | 83 | .TP |
51dad0a9 KB |
84 | LOG_INFO |
85 | Informational messages. | |
86 | .TP | |
87 | LOG_DEBUG | |
88 | Messages that contain information | |
89 | normally of use only when debugging a program. | |
be78fd26 | 90 | .PP |
51dad0a9 KB |
91 | .I Openlog |
92 | provides for more specialized processing of the messages sent | |
93 | by | |
ed6316b8 | 94 | .I syslog |
51dad0a9 KB |
95 | and |
96 | .IR vsyslog . | |
ed6316b8 | 97 | The parameter |
609b3d57 | 98 | .I ident |
51dad0a9 | 99 | is a string that will be prepended to every message. |
ed6316b8 | 100 | .I Logopt |
51dad0a9 KB |
101 | is a bit field specifying logging options, which is formed by |
102 | .IR OR 'ing | |
103 | one or more of the following values: | |
c262cc40 | 104 | .TP |
c262cc40 | 105 | LOG_CONS |
51dad0a9 KB |
106 | If |
107 | .I syslog | |
108 | cannot pass the message to | |
109 | .I syslogd | |
110 | it will attempt to write the message to the console (``/dev/console''). | |
c262cc40 KB |
111 | .TP |
112 | LOG_NDELAY | |
6a71ef00 | 113 | Open the connection to |
ed6316b8 | 114 | .I syslogd |
0c9a57bf | 115 | immediately. |
51dad0a9 KB |
116 | Normally the open is delayed until the first message is logged. |
117 | Useful for programs that need to manage the order in which file | |
118 | descriptors are allocated. | |
c262cc40 | 119 | .TP |
3f4b96b5 | 120 | LOG_PERROR |
51dad0a9 | 121 | Write the message to standard error output as well to the system log. |
3f4b96b5 KB |
122 | .TP |
123 | LOG_PID | |
51dad0a9 KB |
124 | Log the process id with each message: useful for identifying |
125 | instantiations of daemons. | |
ed6316b8 KM |
126 | .PP |
127 | The | |
be78fd26 | 128 | .I facility |
6a71ef00 | 129 | parameter encodes a default facility to be assigned to all messages |
be78fd26 | 130 | that do not have an explicit facility encoded: |
c262cc40 | 131 | .TP |
3f4b96b5 KB |
132 | LOG_AUTH |
133 | The authorization system: | |
134 | .IR login (1), | |
135 | .IR su (1), | |
136 | .IR getty (8), | |
137 | etc. | |
c262cc40 | 138 | .TP |
51dad0a9 KB |
139 | LOG_AUTHPRIV |
140 | The same as LOG_AUTH, but logged to a file readable only by | |
141 | selected individuals. | |
142 | .TP | |
3f4b96b5 KB |
143 | LOG_CRON |
144 | The clock daemon. | |
c262cc40 KB |
145 | .TP |
146 | LOG_DAEMON | |
be78fd26 | 147 | System daemons, such as |
a7aaa6ab | 148 | .IR ftpd (8), |
be78fd26 | 149 | .IR routed (8), |
51dad0a9 | 150 | etc., that are not provided for explicitly by other facilities. |
c262cc40 | 151 | .TP |
3f4b96b5 KB |
152 | LOG_KERN |
153 | Messages generated by the kernel. | |
154 | These cannot be generated by any user processes. | |
c262cc40 KB |
155 | .TP |
156 | LOG_LPR | |
a4e75007 EA |
157 | The line printer spooling system: |
158 | .IR lpr (1), | |
159 | .IR lpc (8), | |
160 | .IR lpd (8), | |
161 | etc. | |
c262cc40 | 162 | .TP |
3f4b96b5 KB |
163 | LOG_MAIL |
164 | The mail system. | |
165 | .TP | |
c262cc40 KB |
166 | LOG_NEWS |
167 | The network news system. | |
168 | .TP | |
3f4b96b5 KB |
169 | LOG_SYSLOG |
170 | Messages generated internally by | |
171 | .IR syslogd (8). | |
172 | .TP | |
173 | LOG_USER | |
174 | Messages generated by random user processes. | |
175 | This is the default facility identifier if none is specified. | |
176 | .TP | |
c262cc40 KB |
177 | LOG_UUCP |
178 | The uucp system. | |
179 | .TP | |
c262cc40 | 180 | LOG_LOCAL0 |
be78fd26 EA |
181 | Reserved for local use. |
182 | Similarly for LOG_LOCAL1 through LOG_LOCAL7. | |
609b3d57 KM |
183 | .PP |
184 | .I Closelog | |
185 | can be used to close the log file. | |
ed6316b8 KM |
186 | .PP |
187 | .I Setlogmask | |
188 | sets the log priority mask to | |
189 | .I maskpri | |
190 | and returns the previous mask. | |
be78fd26 EA |
191 | Calls to |
192 | .I syslog | |
6a71ef00 | 193 | with a priority not set in |
be78fd26 EA |
194 | .I maskpri |
195 | are rejected. | |
6a71ef00 MK |
196 | The mask for an individual priority |
197 | .I pri | |
51dad0a9 | 198 | is calculated by the macro ``LOG_MASK(pri);'' |
6a71ef00 MK |
199 | the mask for all priorities up to and including |
200 | .I toppri | |
51dad0a9 | 201 | is given by the macro ``LOG_UPTO(toppri);''. |
be78fd26 | 202 | The default allows all priorities to be logged. |
609b3d57 KM |
203 | .SH EXAMPLES |
204 | .nf | |
51dad0a9 | 205 | .RS |
be78fd26 | 206 | syslog(LOG_ALERT, "who: internal error 23"); |
609b3d57 | 207 | |
be78fd26 | 208 | openlog("ftpd", LOG_PID, LOG_DAEMON); |
6a71ef00 | 209 | setlogmask(LOG_UPTO(LOG_ERR)); |
609b3d57 | 210 | syslog(LOG_INFO, "Connection from host %d", CallingHost); |
be78fd26 EA |
211 | |
212 | syslog(LOG_INFO|LOG_LOCAL2, "foobar error: %m"); | |
51dad0a9 | 213 | .RE |
609b3d57 | 214 | .fi |
51dad0a9 KB |
215 | .SH RETURNS |
216 | The routines | |
217 | .I closelog , | |
218 | .I openlog , | |
219 | .I syslog | |
220 | and | |
221 | .I vsyslog | |
222 | return 0 upon successful completion. | |
223 | Otherwise, -1 is returned and | |
224 | .I errno | |
225 | is set to indicate the error. | |
226 | .PP | |
227 | The routine | |
228 | .I setlogmask | |
229 | always returns the previous log mask level, never returning | |
230 | an error. | |
231 | .SH ERRORS | |
232 | The routines | |
233 | .I syslog | |
234 | and | |
235 | .I vsyslog | |
236 | may fail and set errno for any of the errors specified for the library | |
237 | routines | |
238 | .IR connect (2), | |
239 | .IR send (2) , | |
240 | and | |
241 | .IR socket (2). | |
242 | .PP | |
243 | The routine | |
244 | .I openlog | |
245 | may fail and set errno for any of the errors specified for the library | |
246 | routines | |
247 | .IR connect (2) | |
248 | and | |
249 | .IR socket (2). | |
250 | .PP | |
251 | The routine | |
252 | .I closelog | |
253 | may fail and set errno for any of the errors specified for the library | |
254 | routine | |
255 | .IR close (2). | |
ed6316b8 | 256 | .SH "SEE ALSO" |
51dad0a9 | 257 | logger(1), syslogd(8) |