📄 syslogd.texi
字号:
@node syslogd@chapter syslogd@cindex syslogd@command{syslogd} is a system service that provides error loggingfacility. Messages are read from the @acronym{UNIX} domain socket@file{/dev/log}, from an Internet domain socket specified in@file{/etc/services}, and from the special device @file{/dev/klog} (toread kernel messages).@command{syslogd} creates the file @file{/var/run/syslog.pid}, andstores its process id there. This can be used to kill or reconfigure@command{syslogd}.The message sent to @command{syslogd} should consist of a single line.The message can contain a priority code, which should be a precedingdecimal number in angle braces, for example, @code{<5>}. Thispriority code should map into the priorities defined in the includefile @code{sys/syslog.h}.@section InvokingThe options are as follows:@table @samp@item -f @var{FILE}@itemx --rcfile=@var{FILE}@opindex -f@opindex --rcfileOverride configuration (the default file is @file{/etc/syslog.conf}).@item --pidfile=@var{FILE}@opindex --pidfileOverride pidfile (the default file is @file{/var/run/syslogd.pid}).@item -n@itemx --no-detach@opindex -n@opindex --no-detachDo not enter daemon mode.@item -d@itemx --debug@opindex -d@opindex --debugPrint debug information (implies @option{-n}).@item -p @var{FILE}@item --socket=@var{FILE}@opindex -p@opindex --socketOverride default @acronym{UNIX} domain socket @file{/dev/log}.@item -a @var{SOCKET}Add @acronym{UNIX} socket to listen. An unlimited number of socketsis allowed.@item -r@itemx --inet@opindex -r@opindex --inetReceive remote messages via Internet domain socket.@item --no-unixaf@opindex --no-unixafDo not listen on @acronym{UNIX} domain sockets (overrides @option{-a}and @option{-p}).@item --no-klog@opindex --no-klogDo not listen to kernel log device @file{/dev/klog}.@item --no-forward@opindex --no-forwardDo not forward any messages (overrides @option{-h}).@item -h@item --hop@opindex -h@opindex --hopForward messages from remote hosts.@item -m INTERVAL@item --mark=@var{INTERVAL}@opindex -m@opindex --markSpecify timestamp interval in logs (0 for no timestamps).@item -l @var{HOSTLIST}@opindex -lLog hosts in @var{HOSTLIST} by their hostname. Multiple lists are allowed.@item -s @var{DOMAINLIST}@opindex -sList of domains which should be stripped from the FQDN of hosts beforelogging their name. Multiple lists are allowed.@end table@section Configuration file@command{syslogd} reads its configuration file when it starts up andwhenever it receives a hangup signal. The @file{syslog.conf} file isthe configuration file for the @command{syslogd} program. It consistsof lines with two fields: the @emph{selector} field which specifiesthe types of messages and priorities to which the line applies, and an@emph{action} field which specifies the action to be taken if amessage @command{syslogd} receives matches the selection criteria.The @emph{selector} field is separated from the action field by one ormore tab or space characters. A rule can be splitted in several linesif all lines except the last are terminated with a backslash @samp{\}.The Selectors function are encoded as a facility, a period (@samp{.}),and a level, with no intervening white-space. Both the facility andthe level are case insensitive.The facility describes the part of the system generating the message,and is one of the following keywords: @samp{auth}, @samp{authpriv},@samp{cron}, @samp{daemon}, @samp{kern}, @samp{lpr}, @samp{mail},@samp{mark}, @samp{news}, @samp{syslog}, @samp{user}, @samp{uucp} and@samp{local0} through @samp{local7}. These keywords (with theexception of @samp{mark}) correspond to the similar @samp{LOG_} valuesspecified to the @samp{openlog} and @samp{syslog} library routines.@xref{Syslog, , Syslog, libc, The GNU C Library Reference Manual}, fordetails.The level describes the severity of the message, and is a keyword fromthe following ordered list (higher to lower): @samp{emerg},@samp{alert}, @samp{crit}, @samp{err, warning}, @samp{notice} and@samp{debug}. These keywords correspond to the similar @samp{LOG_}values specified to the syslog library routine.@xref{syslog; vsyslog, , syslog and vsyslog, libc, The GNU C LibraryReference Manual}, for a further descriptions of both the facility andlevel keywords and their significance.If a received message matches the specified facility and is of thespecified level (or a higher level), the action specified in theaction field will be taken.Multiple selectors may be specified for a single action by separatingthem with semicolon (@samp{;}) characters. It is important to note,however, that each selector can modify the ones preceding it.Multiple facilities may be specified for a single level by separatingthem with comma (@samp{,}) characters.An asterisk (@samp{*}) can be used to specify all facilities or alllevels.By default, a level applies to all messages with the same or higherlevel. The equal (@samp{=}) character can be prepended to a level torestrict this line of the configuration file to messages with the verysame level.An exclamation mark (@samp{!}) prepended to a level or the asteriskmeans that this line of the configuration file does not apply to thespecified level (and higher ones). In conjunction with the equal sign,you can exclude single levels as well.The special facility @emph{mark} receives a message at priority@samp{info} every 20 minutes. This is not enabled by a facility fieldcontaining an asterisk.The special level @samp{none} disables a particular facility.The action field of each line specifies the action to be taken whenthe selector field selects a message. There are five forms:@itemize @bullet@itemA pathname (beginning with a leading slash). Selected messages areappended to the file.You may prepend a minus (@samp{-}) to the path to omit syncing thefile after each message log. This can cause data loss at systemcrashes, but increases performance for programs which use loggingextensively.@itemA named pipe (fifo), beginning with a vertical bar (@samp{|}) followedby a pathname. The pipe must be created with @command{mkfifo}(8)before @command{syslogd} reads its configuration file. This featureis especially useful fo debugging.@itemA hostname (preceded by an at (@samp{@@}) sign). Selected messages areforwarded to @command{syslogd} on the named host.@itemA comma separated list of users. Selected messages are written tothose users if they are logged in.@itemAn asterisk. Selected messages are written to all logged-in users.Blank lines and lines whose first non-blank character is a hash(@samp{#}) character are ignored.@end itemizeA configuration file might appear as follows:@example# Log all kernel messages, authentication messages of# level notice or higher and anything of level err or# higher to the console.# Don't log private authentication messages!*.err;kern.*;auth.notice;authpriv.none /dev/console# Log anything (except mail) of level info or higher.# Don't log private authentication messages!*.info;mail.none;authpriv.none /var/log/messages# The authpriv file has restricted access.authpriv.* /var/log/secure# Log all the mail messages in one place.mail.* /var/log/maillog# Everybody gets emergency messages, plus log them on another# machine.*.emerg **.emerg @@arpa.berkeley.edu# Root and Eric get alert and higher messages.*.alert root,eric# Save mail and news errors of level err and higher in a# special file.uucp,news.crit /var/log/spoolerr@end example@comment @section BUGSThe effects of multiple selectors are sometimes not intuitive. Forexample @samp{mail.crit,*.err} will select the @samp{mail} facilitymessages at the level of @samp{err} or higher, not at the level of@samp{crit} or higher.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -