Commit | Line | Data |
---|---|---|
609b3d57 KM |
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 | .\" | |
ed6316b8 | 5 | .\" @(#)syslog.3 6.1 (Berkeley) %G% |
609b3d57 | 6 | .\" |
ed6316b8 | 7 | .TH SYSLOG 3 "" |
609b3d57 KM |
8 | .UC 5 |
9 | .SH NAME | |
ed6316b8 | 10 | syslog, openlog, closelog, setlogmask \- control system log |
609b3d57 KM |
11 | .SH SYNOPSIS |
12 | .B "#include <syslog.h> | |
13 | .PP | |
ed6316b8 | 14 | .B "openlog(ident, logopt, maskpri) |
609b3d57 KM |
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() | |
ed6316b8 KM |
23 | .PP |
24 | .B "setlogmask(maskpri) | |
609b3d57 KM |
25 | .SH DESCRIPTION |
26 | .I Syslog | |
ed6316b8 | 27 | arranges to write |
609b3d57 KM |
28 | .I message |
29 | onto the system log maintained by | |
ed6316b8 | 30 | .IR syslogd (8). |
609b3d57 KM |
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 | |
ed6316b8 KM |
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 | If | |
46 | .I syslog | |
47 | cannot pass the message to | |
48 | .I syslogd | |
49 | and the message is priority LOG_FAIL or higher, | |
50 | it attempts to write the message on | |
51 | .IR /dev/console. | |
609b3d57 KM |
52 | .PP |
53 | If special processing is needed, | |
54 | .I openlog | |
55 | can be called to initialize the log file. | |
ed6316b8 | 56 | The parameter |
609b3d57 | 57 | .I ident |
ed6316b8 KM |
58 | is a string that is prepended to every message. |
59 | .I Logopt | |
60 | is a bit field indicating logging options. | |
61 | Current values for | |
62 | .I logopt | |
63 | are: | |
64 | .IP LOG_PID \w'LOG_ODELAY'u+3 | |
609b3d57 KM |
65 | log the process id with each message: |
66 | useful for identifying instantiations of daemons. | |
ed6316b8 KM |
67 | .IP LOG_CONS \w'LOG_ODELAY'u+3 |
68 | Force writing error messages to the console if unable to send it to | |
69 | .I syslogd. | |
70 | This option is safe to use in daemon processes that have no controlling | |
71 | terminal since | |
72 | .I syslog | |
73 | will fork before opening the console. | |
74 | .IP LOG_ODELAY \w'LOG_ODELAY'u+3 | |
75 | Delay opening the connection to | |
76 | .I syslogd | |
77 | until the first error occurs. Useful for programs that need to manage the | |
78 | order in which file descriptors are allocated. | |
79 | .PP | |
80 | The | |
81 | .I maskpri | |
82 | parameter is a mask for screening out low priority messages. | |
83 | Calls to | |
84 | .I syslog | |
85 | with a priority whose corresponding bit in | |
86 | .I maskpri | |
87 | is not set are ignored. | |
88 | The default allows all priorities to be logged. | |
609b3d57 KM |
89 | .PP |
90 | .I Closelog | |
91 | can be used to close the log file. | |
ed6316b8 KM |
92 | .PP |
93 | .I Setlogmask | |
94 | sets the log priority mask to | |
95 | .I maskpri | |
96 | and returns the previous mask. | |
97 | Priorities and masks of 0 are ignored. | |
609b3d57 KM |
98 | .SH EXAMPLES |
99 | .nf | |
100 | syslog(LOG_SALERT, "who: internal error 23"); | |
101 | ||
ed6316b8 | 102 | openlog("serverftp", LOG_PID, 0); |
609b3d57 KM |
103 | syslog(LOG_INFO, "Connection from host %d", CallingHost); |
104 | .fi | |
ed6316b8 KM |
105 | .SH "SEE ALSO" |
106 | syslogd(8) |