|
|
1.1 root 1: .\" Copyright (c) 1983 Regents of the University of California.
2: .\" All rights reserved. The Berkeley software License Agreement
3: .\" specifies the terms and conditions for redistribution.
4: .\"
5: .\" @(#)syslog.3 6.6 (Berkeley) 5/15/86
6: .\"
7: .TH SYSLOG 3 "May 15, 1986"
8: .UC 5
9: .SH NAME
10: syslog, openlog, closelog, setlogmask \- control system log
11: .SH SYNOPSIS
12: .B "#include <syslog.h>
13: .PP
14: .B "openlog(ident, logopt, facility)
15: .br
16: .B "char *ident;
17: .PP
18: .B "syslog(priority, message, parameters ... )
19: .br
20: .B "char *message;
21: .PP
22: .B "closelog()
23: .PP
24: .B "setlogmask(maskpri)
25: .SH DESCRIPTION
26: .I Syslog
27: arranges to write
28: .I message
29: onto the system log maintained by
30: .IR syslogd (8).
31: The message is tagged with
32: .IR priority .
33: The message looks like a
34: .IR printf (3)
35: string except that
36: .B %m
37: is replaced by the current error message (collected from
38: .IR errno ).
39: A trailing newline is added if needed.
40: This message will be read by
41: .IR syslogd (8)
42: and written to the system console, log files, or forwarded to
43: .I syslogd
44: on another host as appropriate.
45: .PP
46: Priorities are encoded as a
47: .I facility
48: and a
49: .IR level .
50: The facility describes the part of the system
51: generating the message.
52: The level is selected from an ordered list:
53: .IP LOG_EMERG \w'LOG_WARNING'u+3
54: A panic condition.
55: This is normally broadcast to all users.
56: .IP LOG_ALERT \w'LOG_WARNING'u+3
57: A condition that should be corrected immediately,
58: such as a corrupted system database.
59: .IP LOG_CRIT \w'LOG_WARNING'u+3
60: Critical conditions,
61: e.g., hard device errors.
62: .IP LOG_ERR \w'LOG_WARNING'u+3
63: Errors.
64: .IP LOG_WARNING \w'LOG_WARNING'u+3
65: Warning messages.
66: .IP LOG_NOTICE \w'LOG_WARNING'u+3
67: Conditions that are not error conditions,
68: but should possibly be handled specially.
69: .IP LOG_INFO \w'LOG_WARNING'u+3
70: Informational messages.
71: .IP LOG_DEBUG \w'LOG_WARNING'u+3
72: Messages that contain information
73: normally of use only when debugging a program.
74: .PP
75: If
76: .I syslog
77: cannot pass the message to
78: .IR syslogd ,
79: it will attempt to write the message on
80: .I /dev/console
81: if the LOG_CONS option is set (see below).
82: .PP
83: If special processing is needed,
84: .I openlog
85: can be called to initialize the log file.
86: The parameter
87: .I ident
88: is a string that is prepended to every message.
89: .I Logopt
90: is a bit field indicating logging options.
91: Current values for
92: .I logopt
93: are:
94: .IP LOG_PID \w'LOG_WARNING'u+3
95: log the process id with each message:
96: useful for identifying instantiations of daemons.
97: .IP LOG_CONS \w'LOG_WARNING'u+3
98: Force writing messages to the console if unable to send it to
99: .I syslogd.
100: This option is safe to use in daemon processes that have no controlling
101: terminal since
102: .I syslog
103: will fork before opening the console.
104: .IP LOG_NDELAY \w'LOG_WARNING'u+3
105: Open the connection to
106: .I syslogd
107: immediately.
108: Normally the open is delayed
109: until the first message is logged.
110: Useful for programs that need to manage the
111: order in which file descriptors are allocated.
112: .IP LOG_NOWAIT \w'LOG_WARNING'u+3
113: Don't wait for children forked to log messages on the console.
114: This option should be used by processes that enable notification
115: of child termination via SIGCHLD, as
116: .I syslog
117: may otherwise block waiting for a child whose exit status has already
118: been collected.
119: .PP
120: The
121: .I facility
122: parameter encodes a default facility to be assigned to all messages
123: that do not have an explicit facility encoded:
124: .IP LOG_KERN \w'LOG_WARNING'u+3
125: Messages generated by the kernel.
126: These cannot be generated by any user processes.
127: .IP LOG_USER \w'LOG_WARNING'u+3
128: Messages generated by random user processes.
129: This is the default facility identifier if none is specified.
130: .IP LOG_MAIL \w'LOG_WARNING'u+3
131: The mail system.
132: .IP LOG_DAEMON \w'LOG_WARNING'u+3
133: System daemons, such as
134: .IR ftpd (8),
135: .IR routed (8),
136: etc.
137: .IP LOG_AUTH \w'LOG_WARNING'u+3
138: The authorization system:
139: .IR login (1),
140: .IR su (1),
141: .IR getty (8),
142: etc.
143: .IP LOG_LPR \w'LOG_WARNING'u+3
144: The line printer spooling system:
145: .IR lpr (1),
146: .IR lpc (8),
147: .IR lpd (8),
148: etc.
149: .IP LOG_LOCAL0 \w'LOG_WARNING'u+3
150: Reserved for local use.
151: Similarly for LOG_LOCAL1 through LOG_LOCAL7.
152: .PP
153: .I Closelog
154: can be used to close the log file.
155: .PP
156: .I Setlogmask
157: sets the log priority mask to
158: .I maskpri
159: and returns the previous mask.
160: Calls to
161: .I syslog
162: with a priority not set in
163: .I maskpri
164: are rejected.
165: The mask for an individual priority
166: .I pri
167: is calculated by the macro LOG_MASK(\fIpri\fP);
168: the mask for all priorities up to and including
169: .I toppri
170: is given by the macro LOG_UPTO(\fItoppri\fP).
171: The default allows all priorities to be logged.
172: .SH EXAMPLES
173: .nf
174: syslog(LOG_ALERT, "who: internal error 23");
175:
176: openlog("ftpd", LOG_PID, LOG_DAEMON);
177: setlogmask(LOG_UPTO(LOG_ERR));
178: syslog(LOG_INFO, "Connection from host %d", CallingHost);
179:
180: syslog(LOG_INFO|LOG_LOCAL2, "foobar error: %m");
181: .fi
182: .SH "SEE ALSO"
183: logger(1),
184: syslogd(8)
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.