syslog.3
来自「早期freebsd实现」· 3 代码 · 共 240 行
3
240 行
.\" $Revision: 1.2 $.\" Copyright (c) 1985 The Regents of the University of California..\" All rights reserved..\".\" Redistribution and use in source and binary forms are permitted provided.\" that: (1) source distributions retain this entire copyright notice and.\" comment, and (2) distributions including binaries display the following.\" acknowledgement: ``This product includes software developed by the.\" University of California, Berkeley and its contributors'' in the.\" documentation or other materials provided with the distribution and in.\" all advertising materials mentioning features or use of this software..\" Neither the name of the University nor the names of its contributors may.\" be used to endorse or promote products derived from this software without.\" specific prior written permission..\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE..\".\" @(#)syslog.3 6.13 (Berkeley) 6/23/90.\".TH SYSLOG 3 "June 23, 1990".UC 5.SH NAMEsyslog, openlog, closelog, setlogmask, vsyslog \- control system log.SH SYNOPSIS.B "#include <syslog.h>.PP.B "openlog(ident, logopt, facility).br.B "char *ident;.PP.B "syslog(priority, message, parameters ... ).br.B "int priority;.br.B "char *message;.PP.B "#include <varargs.h>.br.B "vsyslog(priority, message, args).br.B "int priority;.br.B "char *message;.br.B "va_list args;.PP.B "closelog().PP.B "setlogmask(maskpri).SH DESCRIPTION.I Syslogarranges to write.I messageonto the system log maintained by.IR syslogd (8).The message is tagged with.IR priority .The message looks like a.IR printf (3)string except that.B %mis replaced by the current error message (as referenced by.IR errno ).A trailing newline is added if needed.An alternate form, in which the arguments have already been capturedusing the variable-length argument facilities of.IR varargs (3),is available under the name.IR vsyslog ..PPThis message will be read by.IR syslogd (8)and written to the system console, log files, or forwarded to.I syslogdon another host as appropriate..PPPriorities are encoded as a.I facilityand a.IR level .The facility describes the part of the systemgenerating the message.The level is selected from an ordered list:.TPLOG_ALERTA condition that should be corrected immediately,such as a corrupted system database..TPLOG_CRITCritical conditions,e.g., hard device errors..TPLOG_DEBUGMessages that contain informationnormally of use only when debugging a program..TPLOG_EMERGA panic condition.This is normally broadcast to all users..TPLOG_ERRErrors..TPLOG_INFOInformational messages..TPLOG_NOTICEConditions that are not error conditions,but should possibly be handled specially..TPLOG_WARNINGWarning messages..PPIf.I syslogcannot pass the message to.IR syslogd ,it will attempt to write the message to the console (``/dev/console'')if the LOG_CONS option is set (see below)..PPIf special processing is needed,.I openlogcan be called to initialize the log file.The parameter.I identis a string that is prepended to every message..I Logoptis a bit field indicating logging options.Current values for.I logoptare:.TPLOG_CONSIf unable to send the message to.IR syslogd ,write it to the console..TPLOG_NDELAY Open the connection to.I syslogdimmediately.Normally the open is delayeduntil the first message is logged.Useful for programs that need to manage theorder in which file descriptors are allocated..TPLOG_PERRORWrite the message to stderr as well to the system log..TPLOG_PIDLog the process id with each message:useful for identifying instantiations of daemons..PPThe.I facilityparameter encodes a default facility to be assigned to all messagesthat do not have an explicit facility encoded:.TPLOG_AUTHThe authorization system:.IR login (1),.IR su (1),.IR getty (8),etc..TPLOG_CRONThe clock daemon..TPLOG_DAEMONSystem daemons, such as.IR ftpd (8),.IR routed (8),etc, that are not provided for explicitly by other facilities..TPLOG_KERNMessages generated by the kernel.These cannot be generated by any user processes..TPLOG_LPRThe line printer spooling system:.IR lpr (1),.IR lpc (8),.IR lpd (8),etc..TPLOG_MAILThe mail system..TPLOG_NEWSThe network news system..TPLOG_SYSLOGMessages generated internally by.IR syslogd (8)..TPLOG_USERMessages generated by random user processes.This is the default facility identifier if none is specified..TPLOG_UUCPThe uucp system..TPLOG_LOCAL0Reserved for local use.Similarly for LOG_LOCAL1 through LOG_LOCAL7..PP.I Closelogcan be used to close the log file..PP.I Setlogmasksets the log priority mask to.I maskpriand returns the previous mask.Calls to.I syslogwith a priority not set in.I maskpriare rejected.The mask for an individual priority.I priis calculated by the macro LOG_MASK(\fIpri\fP);the mask for all priorities up to and including.I toppriis given by the macro LOG_UPTO(\fItoppri\fP).The default allows all priorities to be logged..SH EXAMPLES.nfsyslog(LOG_ALERT, "who: internal error 23");openlog("ftpd", LOG_PID, LOG_DAEMON);setlogmask(LOG_UPTO(LOG_ERR));syslog(LOG_INFO, "Connection from host %d", CallingHost);syslog(LOG_INFO|LOG_LOCAL2, "foobar error: %m");.fi.SH "SEE ALSO"logger(1),syslogd(8)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?