| 1 | .TH SYSLOG 3 |
| 2 | .\" @(#)syslog.3 4.1 %G% |
| 3 | .SH NAME |
| 4 | syslog, openlog, closelog -- control system log |
| 5 | .SH SYNOPSIS |
| 6 | # include <syslog.h> |
| 7 | .PP |
| 8 | openlog(ident, logstat) |
| 9 | .br |
| 10 | char *ident; |
| 11 | .PP |
| 12 | syslog(priority, message, parameters ... ) |
| 13 | .br |
| 14 | char *message; |
| 15 | .PP |
| 16 | closelog() |
| 17 | .SH DESCRIPTION |
| 18 | .I Syslog |
| 19 | arranges to |
| 20 | write the |
| 21 | .I message |
| 22 | onto the |
| 23 | system log maintained by |
| 24 | .IR syslog (8). |
| 25 | The message is tagged with |
| 26 | .I priority. |
| 27 | The message looks like a |
| 28 | .I printf(3) |
| 29 | string except that |
| 30 | .B %m |
| 31 | is replaced by the current error message |
| 32 | (collected from |
| 33 | .I errno\c |
| 34 | ). |
| 35 | A trailing newline is added if needed. |
| 36 | This message will be read by |
| 37 | .I syslog(8) |
| 38 | and output to the system console or files as appropriate. |
| 39 | .PP |
| 40 | If special processing is needed, |
| 41 | .I openlog |
| 42 | can be called to initialize the log file. |
| 43 | Parameters are |
| 44 | .I ident |
| 45 | which is prepended to every message, |
| 46 | and |
| 47 | .I logstat |
| 48 | which is |
| 49 | a bit field indicating special status; |
| 50 | current values are: |
| 51 | .IP LOG_PID \w'LOG_PID'u+3 |
| 52 | log the process id with each message: |
| 53 | useful for identifying instantiations of daemons. |
| 54 | .LP |
| 55 | .I Openlog |
| 56 | returns zero on success. |
| 57 | If it cannot open the file |
| 58 | .I /dev/log, |
| 59 | it writes on |
| 60 | .I /dev/console |
| 61 | instead and returns -1. |
| 62 | .PP |
| 63 | .I Closelog |
| 64 | can be used to close the log file. |
| 65 | .SH EXAMPLES |
| 66 | .nf |
| 67 | syslog(LOG_SALERT, "who: internal error 23"); |
| 68 | |
| 69 | openlog("serverftp", LOG_PID); |
| 70 | syslog(LOG_INFO, "Connection from host %d", CallingHost); |
| 71 | .fi |
| 72 | .SH SEE\ ALSO |
| 73 | syslog(8) |