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