📄 syslog.3
字号:
.\" Copyright (c) 1985, 1991, 1993.\" The Regents of the University of California. All rights reserved..\".\" Redistribution and use in source and binary forms, with or without.\" modification, are permitted provided that the following conditions.\" are met:.\" 1. Redistributions of source code must retain the above copyright.\" notice, this list of conditions and the following disclaimer..\" 2. Redistributions in binary form must reproduce the above copyright.\" notice, this list of conditions and the following disclaimer in the.\" documentation and/or other materials provided with the distribution..\" 3. All advertising materials mentioning features or use of this software.\" must display the following acknowledgement:.\" This product includes software developed by the University of.\" California, Berkeley and its contributors..\" 4. 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 BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION).\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF.\" SUCH DAMAGE..\".\" @(#)syslog.3 8.1 (Berkeley) 6/4/93.\".Dd June 4, 1993.Dt SYSLOG 3.Os BSD 4.2.Sh NAME.Nm syslog ,.Nm vsyslog ,.Nm openlog ,.Nm closelog ,.Nm setlogmask.Nd control system log.Sh SYNOPSIS.Fd #include <syslog.h>.Fd #include <varargs.h>.Ft void.Fn syslog "int priority" "const char *message" "...".Ft void.Fn vsyslog "int priority" "const char *message" "va_list args".Ft void.Fn openlog "const char *ident" "int logopt" "int facility".Ft void.Fn closelog void.Ft int.Fn setlogmask "int maskpri".Sh DESCRIPTIONThe.Fn syslogfunctionwrites.Fa messageto the system message logger.The message is then written to the system console, log files,logged-in users, or forwarded to other machines as appropriate. (See.Xr syslogd 8 . ).PpThe message is identical to a.Xr printf 3format string, except that.Ql %mis replaced by the current errormessage. (As denoted by the global variable.Va errno ;see.Xr strerror 3 . )A trailing newline is added if none is present..PpThe.Fn vsyslogfunctionis an alternate form in which the arguments have already been capturedusing the variable-length argument facilities of.Xr varargs 3 ..PpThe message is tagged with.Fa priority .Priorities are encoded as a.Fa facilityand a.Em level .The facility describes the part of the systemgenerating the message.The level is selected from the following.Em ordered(high to low) list:.Bl -tag -width LOG_AUTHPRIV.It Dv LOG_EMERGA panic condition.This is normally broadcast to all users..It Dv LOG_ALERTA condition that should be corrected immediately, such as a corruptedsystem database..It Dv LOG_CRITCritical conditions, e.g., hard device errors..It Dv LOG_ERRErrors..It Dv LOG_WARNINGWarning messages..It Dv LOG_NOTICEConditions that are not error conditions,but should possibly be handled specially..It Dv LOG_INFOInformational messages..It Dv LOG_DEBUGMessages that contain informationnormally of use only when debugging a program..El.PpThe.Fn openlogfunctionprovides for more specialized processing of the messages sentby.Fn syslogand.Fn vsyslog .The parameter.Fa identis a string that will be prepended to every message.The.Fa logoptargumentis a bit field specifying logging options, which is formed by.Tn OR Ns 'ingone or more of the following values:.Bl -tag -width LOG_AUTHPRIV.It Dv LOG_CONSIf.Fn syslogcannot pass the message to.Xr syslogdit will attempt to write the message to the console.Pq Dq Pa /dev/console..It Dv LOG_NDELAY Open the connection to.Xr syslogdimmediately.Normally the open is delayed until the first message is logged.Useful for programs that need to manage the order in which filedescriptors are allocated..It Dv LOG_PERRORWrite the message to standard error output as well to the system log..It Dv LOG_PIDLog the process id with each message: useful for identifyinginstantiations of daemons..El.PpThe.Fa facilityparameter encodes a default facility to be assigned to all messagesthat do not have an explicit facility encoded:.Bl -tag -width LOG_AUTHPRIV.It Dv LOG_AUTHThe authorization system:.Xr login 1 ,.Xr su 1 ,.Xr getty 8 ,etc..It Dv LOG_AUTHPRIVThe same as.Dv LOG_AUTH ,but logged to a file readable only byselected individuals..It Dv LOG_CRONThe clock daemon..It Dv LOG_DAEMONSystem daemons, such as.Xr routed 8 ,that are not provided for explicitly by other facilities..It Dv LOG_KERNMessages generated by the kernel.These cannot be generated by any user processes..It Dv LOG_LPRThe line printer spooling system:.Xr lpr 1 ,.Xr lpc 8 ,.Xr lpd 8 ,etc..It Dv LOG_MAILThe mail system..It Dv LOG_NEWSThe network news system..It Dv LOG_SYSLOGMessages generated internally by.Xr syslogd 8 ..It Dv LOG_USERMessages generated by random user processes.This is the default facility identifier if none is specified..It Dv LOG_UUCPThe uucp system..It Dv LOG_LOCAL0Reserved for local use.Similarly for.Dv LOG_LOCAL1through.Dv LOG_LOCAL7 ..El .PpThe.Fn closelogfunctioncan be used to close the log file..PpThe.Fn setlogmaskfunctionsets the log priority mask to.Fa maskpriand returns the previous mask.Calls to.Fn syslogwith a priority not set in.Fa maskpriare rejected.The mask for an individual priority.Fa priis calculated by the macro.Fn LOG_MASK pri ;the mask for all priorities up to and including.Fa toppriis given by the macro.Fn LOG_UPTO toppri ; .The default allows all priorities to be logged..Sh RETURN VALUESThe routines.Fn closelog ,.Fn openlog ,.Fn syslogand.Fn vsyslogreturn no value..PpThe routine.Fn setlogmaskalways returns the previous log mask level..Sh EXAMPLES.Bd -literal -offset indent -compactsyslog(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");.Ed.Sh SEE ALSO.Xr logger 1 ,.Xr syslogd 8.Sh HISTORYThesefunctions appeared in .Bx 4.2 .
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -