|
|
1.1 root 1: .\" Copyright (c) 1985 The Regents of the University of California.
2: .\" All rights reserved.
3: .\"
4: .\" Redistribution and use in source and binary forms are permitted provided
5: .\" that: (1) source distributions retain this entire copyright notice and
6: .\" comment, and (2) distributions including binaries display the following
7: .\" acknowledgement: ``This product includes software developed by the
8: .\" University of California, Berkeley and its contributors'' in the
9: .\" documentation or other materials provided with the distribution and in
10: .\" all advertising materials mentioning features or use of this software.
11: .\" Neither the name of the University nor the names of its contributors may
12: .\" be used to endorse or promote products derived from this software without
13: .\" specific prior written permission.
14: .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
15: .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
16: .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
17: .\"
18: .\" @(#)syslog.3 6.13 (Berkeley) 6/23/90
19: .\"
20: .TH SYSLOG 3 "June 23, 1990"
21: .UC 5
22: .SH NAME
23: syslog, openlog, closelog, setlogmask, vsyslog \- control system log
24: .SH SYNOPSIS
25: .B "#include <syslog.h>
26: .PP
27: .B "openlog(ident, logopt, facility)
28: .br
29: .B "char *ident;
30: .PP
31: .B "syslog(priority, message, parameters ... )
32: .br
33: .B "int priority;
34: .br
35: .B "char *message;
36: .PP
37: .B "#include <varargs.h>
38: .br
39: .B "vsyslog(priority, message, args)
40: .br
41: .B "int priority;
42: .br
43: .B "char *message;
44: .br
45: .B "va_list args;
46: .PP
47: .B "closelog()
48: .PP
49: .B "setlogmask(maskpri)
50: .SH DESCRIPTION
51: .I Syslog
52: arranges to write
53: .I message
54: onto the system log maintained by
55: .IR syslogd (8).
56: The message is tagged with
57: .IR priority .
58: The message looks like a
59: .IR printf (3)
60: string except that
61: .B %m
62: is replaced by the current error message (as referenced by
63: .IR errno ).
64: A trailing newline is added if needed.
65: An alternate form, in which the arguments have already been captured
66: using the variable-length argument facilities of
67: .IR varargs (3),
68: is available under the name
69: .IR vsyslog .
70: .PP
71: This message will be read by
72: .IR syslogd (8)
73: and written to the system console, log files, or forwarded to
74: .I syslogd
75: on another host as appropriate.
76: .PP
77: Priorities are encoded as a
78: .I facility
79: and a
80: .IR level .
81: The facility describes the part of the system
82: generating the message.
83: The level is selected from an ordered list:
84: .TP
85: LOG_ALERT
86: A condition that should be corrected immediately,
87: such as a corrupted system database.
88: .TP
89: LOG_CRIT
90: Critical conditions,
91: e.g., hard device errors.
92: .TP
93: LOG_DEBUG
94: Messages that contain information
95: normally of use only when debugging a program.
96: .TP
97: LOG_EMERG
98: A panic condition.
99: This is normally broadcast to all users.
100: .TP
101: LOG_ERR
102: Errors.
103: .TP
104: LOG_INFO
105: Informational messages.
106: .TP
107: LOG_NOTICE
108: Conditions that are not error conditions,
109: but should possibly be handled specially.
110: .TP
111: LOG_WARNING
112: Warning messages.
113: .PP
114: If
115: .I syslog
116: cannot pass the message to
117: .IR syslogd ,
118: it will attempt to write the message to the console (``/dev/console'')
119: if the LOG_CONS option is set (see below).
120: .PP
121: If special processing is needed,
122: .I openlog
123: can be called to initialize the log file.
124: The parameter
125: .I ident
126: is a string that is prepended to every message.
127: .I Logopt
128: is a bit field indicating logging options.
129: Current values for
130: .I logopt
131: are:
132: .TP
133: LOG_CONS
134: If unable to send the message to
135: .IR syslogd ,
136: write it to the console.
137: .TP
138: LOG_NDELAY
139: Open the connection to
140: .I syslogd
141: immediately.
142: Normally the open is delayed
143: until the first message is logged.
144: Useful for programs that need to manage the
145: order in which file descriptors are allocated.
146: .TP
147: LOG_PERROR
148: Write the message to stderr as well to the system log.
149: .TP
150: LOG_PID
151: Log the process id with each message:
152: useful for identifying instantiations of daemons.
153: .PP
154: The
155: .I facility
156: parameter encodes a default facility to be assigned to all messages
157: that do not have an explicit facility encoded:
158: .TP
159: LOG_AUTH
160: The authorization system:
161: .IR login (1),
162: .IR su (1),
163: .IR getty (8),
164: etc.
165: .TP
166: LOG_CRON
167: The clock daemon.
168: .TP
169: LOG_DAEMON
170: System daemons, such as
171: .IR ftpd (8),
172: .IR routed (8),
173: etc, that are not provided for explicitly by other facilities.
174: .TP
175: LOG_KERN
176: Messages generated by the kernel.
177: These cannot be generated by any user processes.
178: .TP
179: LOG_LPR
180: The line printer spooling system:
181: .IR lpr (1),
182: .IR lpc (8),
183: .IR lpd (8),
184: etc.
185: .TP
186: LOG_MAIL
187: The mail system.
188: .TP
189: LOG_NEWS
190: The network news system.
191: .TP
192: LOG_SYSLOG
193: Messages generated internally by
194: .IR syslogd (8).
195: .TP
196: LOG_USER
197: Messages generated by random user processes.
198: This is the default facility identifier if none is specified.
199: .TP
200: LOG_UUCP
201: The uucp system.
202: .TP
203: LOG_LOCAL0
204: Reserved for local use.
205: Similarly for LOG_LOCAL1 through LOG_LOCAL7.
206: .PP
207: .I Closelog
208: can be used to close the log file.
209: .PP
210: .I Setlogmask
211: sets the log priority mask to
212: .I maskpri
213: and returns the previous mask.
214: Calls to
215: .I syslog
216: with a priority not set in
217: .I maskpri
218: are rejected.
219: The mask for an individual priority
220: .I pri
221: is calculated by the macro LOG_MASK(\fIpri\fP);
222: the mask for all priorities up to and including
223: .I toppri
224: is given by the macro LOG_UPTO(\fItoppri\fP).
225: The default allows all priorities to be logged.
226: .SH EXAMPLES
227: .nf
228: syslog(LOG_ALERT, "who: internal error 23");
229:
230: openlog("ftpd", LOG_PID, LOG_DAEMON);
231: setlogmask(LOG_UPTO(LOG_ERR));
232: syslog(LOG_INFO, "Connection from host %d", CallingHost);
233:
234: syslog(LOG_INFO|LOG_LOCAL2, "foobar error: %m");
235: .fi
236: .SH "SEE ALSO"
237: logger(1),
238: syslogd(8)
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.