1SYSLOG(3) 386BSD Programmer's Manual SYSLOG(3) 2 3NNAAMMEE 4 ssyysslloogg, vvssyysslloogg, ooppeennlloogg, cclloosseelloogg, sseettllooggmmaasskk - control system log 5 6SSYYNNOOPPSSIISS 7 ##iinncclluuddee <<ssyysslloogg..hh>> 8 ##iinncclluuddee <<vvaarraarrggss..hh>> 9 10 _v_o_i_d 11 ssyysslloogg(_i_n_t _p_r_i_o_r_i_t_y, _c_o_n_s_t _c_h_a_r *_m_e_s_s_a_g_e, ...) 12 13 _v_o_i_d 14 vvssyysslloogg(_i_n_t _p_r_i_o_r_i_t_y, _c_o_n_s_t _c_h_a_r *_m_e_s_s_a_g_e, _v_a__l_i_s_t _a_r_g_s) 15 16 _v_o_i_d 17 ooppeennlloogg(_c_o_n_s_t _c_h_a_r *_i_d_e_n_t, _i_n_t _l_o_g_o_p_t, _i_n_t _f_a_c_i_l_i_t_y) 18 19 _v_o_i_d 20 cclloosseelloogg(_v_o_i_d) 21 22 _i_n_t 23 sseettllooggmmaasskk(_i_n_t _m_a_s_k_p_r_i) 24 25DDEESSCCRRIIPPTTIIOONN 26 The ssyysslloogg() function writes _m_e_s_s_a_g_e to the system message logger. The 27 message is then written to the system console, log files, logged-in 28 users, or forwarded to other machines as appropriate. (See syslogd(8).) 29 30 The message is identical to a printf(3) format string, except that `%m' 31 is replaced by the current error message. (As denoted by the global 32 variable _e_r_r_n_o; see strerror(3).) A trailing newline is added if none is 33 present. 34 35 The vvssyysslloogg() function is an alternate form in which the arguments have 36 already been captured using the variable-length argument facilities of 37 varargs(3). 38 39 The message is tagged with _p_r_i_o_r_i_t_y. Priorities are encoded as a _f_a_c_i_l_i_t_y 40 and a _l_e_v_e_l. The facility describes the part of the system generating the 41 message. The level is selected from the following _o_r_d_e_r_e_d (high to low) 42 list: 43 44 LOG_EMERG A panic condition. This is normally broadcast to all 45 users. 46 47 LOG_ALERT A condition that should be corrected immediately, such as a 48 corrupted system database. 49 50 LOG_CRIT Critical conditions, e.g., hard device errors. 51 52 LOG_ERR Errors. 53 54 LOG_WARNING Warning messages. 55 56 LOG_NOTICE Conditions that are not error conditions, but should 57 possibly be handled specially. 58 59 LOG_INFO Informational messages. 60 61 LOG_DEBUG Messages that contain information normally of use only when 62 debugging a program. 63 64 The ooppeennlloogg() function provides for more specialized processing of the 65 messages sent by ssyysslloogg() and vvssyysslloogg(). The parameter _i_d_e_n_t is a string 66 that will be prepended to every message. The _l_o_g_o_p_t argument is a bit 67 field specifying logging options, which is formed by OR'ing one or more 68 of the following values: 69 70 LOG_CONS If ssyysslloogg() cannot pass the message to syslogd it will 71 attempt to write the message to the console 72 (``/_d_e_v/_c_o_n_s_o_l_e.'') 73 74 LOG_NDELAY Open the connection to syslogd immediately. Normally the 75 open is delayed until the first message is logged. Useful 76 for programs that need to manage the order in which file 77 descriptors are allocated. 78 79 LOG_PERROR Write the message to standard error output as well to the 80 system log. 81 82 LOG_PID Log the process id with each message: useful for 83 identifying instantiations of daemons. 84 85 The _f_a_c_i_l_i_t_y parameter encodes a default facility to be assigned to all 86 messages that do not have an explicit facility encoded: 87 88 LOG_AUTH The authorization system: login(1), su(1), getty(8), 89 etc. 90 91 LOG_AUTHPRIV The same as LOG_AUTH, but logged to a file readable only by 92 selected individuals. 93 94 LOG_CRON The clock daemon. 95 96 LOG_DAEMON System daemons, such as ftpd(8), routed(8), etc., that 97 are not provided for explicitly by other facilities. 98 99 LOG_KERN Messages generated by the kernel. These cannot be 100 generated by any user processes. 101 102 LOG_LPR The line printer spooling system: lpr(1), lpc(8), lpd(8), 103 etc. 104 105 LOG_MAIL The mail system. 106 107 LOG_NEWS The network news system. 108 109 LOG_SYSLOG Messages generated internally by syslogd(8). 110 111 LOG_USER Messages generated by random user processes. This is the 112 default facility identifier if none is specified. 113 114 LOG_UUCP The uucp system. 115 116 LOG_LOCAL0 Reserved for local use. Similarly for LOG_LOCAL1 through 117 LOG_LOCAL7. 118 119 The cclloosseelloogg() function can be used to close the log file. 120 121 The sseettllooggmmaasskk() function sets the log priority mask to _m_a_s_k_p_r_i and 122 returns the previous mask. Calls to ssyysslloogg() with a priority not set in 123 _m_a_s_k_p_r_i are rejected. The mask for an individual priority _p_r_i is 124 calculated by the macro LLOOGG__MMAASSKK(_p_r_i); the mask for all priorities up to 125 and including _t_o_p_p_r_i is given by the macro LLOOGG__UUPPTTOO(_t_o_p_p_r_i);. The default 126 allows all priorities to be logged. 127 128RREETTUURRNN VVAALLUUEESS 129 The routines cclloosseelloogg(), ooppeennlloogg(), ssyysslloogg() and vvssyysslloogg() return no 130 value. 131 132 133 The routine sseettllooggmmaasskk() always returns the previous log mask level. 134 135EEXXAAMMPPLLEESS 136 syslog(LOG_ALERT, "who: internal error 23"); 137 138 openlog("ftpd", LOG_PID, LOG_DAEMON); 139 setlogmask(LOG_UPTO(LOG_ERR)); 140 syslog(LOG_INFO, "Connection from host %d", CallingHost); 141 142 syslog(LOG_INFO|LOG_LOCAL2, "foobar error: %m"); 143 144SSEEEE AALLSSOO 145 logger(1), syslogd(8) 146 147HHIISSTTOORRYY 148 These functions appeared in 4.2BSD. 149 1504.2 Berkeley Distribution April 19, 1991 3 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199