Linux rsyslog学习教程使用方法(2)-配置文件详解

Linux 1549℃

rsyslog的配置文件路径是:/etc/rsyslog.conf 。有关该文件的更多帮助介绍信息可参阅:/usr/share/doc/rsyslog-*/rsyslog_conf.html。也可以请访问 官方帮助文档

以下内容是rsyslog配置文件的详细说明:

#### MODULES ####    加载模块
$ModLoad imuxsock.so    # 提供对本地系统日志记录的支持(例如通过logger命令)
$ModLoad imklog.so      # 提供内核日志记录支持(以前由rklogd完成)
#$ModLoad immark.so     # 提供--MARK--消息功能
# Provides UDP syslog reception    允许UDP的514端口接收日志
#$ModLoad imudp.so
#$UDPServerRun 514
# Provides TCP syslog reception    允许TCP的514端口接收日志
#$ModLoad imtcp.so
#$InputTCPServerRun 514
#### GLOBAL DIRECTIVES ####    全局指令
# Use default timestamp format    使用默认时间戳
$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat
# File syncing capability is disabled by default. This feature is usually not required,    默认禁用文件同步功能。此功能不常用,
# not useful and an extreme performance hit    不使用时性能极高
#$ActionFileEnableSync on
# Include all config files in /etc/rsyslog.d/    引入/etc/rsyslog.d/中包含所有配置文件
$IncludeConfig /etc/rsyslog.d/*.conf    
#### RULES ####    规则
# Log all kernel messages to the console.    将所有内核消息记录到控制台
# Logging much else clutters up the screen.    在屏幕上记录很多其他的杂项
#kern.*                                                 /dev/console    #关于内核的所有日志都放到/dev/console(控制台)
# Log anything (except mail) of level info or higher.    记录级别信息或更高级别的信息(邮件除外)
# Don't log private authentication messages!    不要登录私人认证信息!
*.info;mail.none;authpriv.none;cron.none                /var/log/messages    记录所有日志类型的info级别以及大于info级别的信息到/var/log/messages,但是mail邮件信息,authpriv验证方面的信息和cron时间任务相关的信息除外
# The authpriv file has restricted access.    authpriv验证相关的所有信息存放在/var/log/secure
authpriv.*                                              /var/log/secure
# Log all the mail messages in one place.    将所有邮件记录在一个地方
mail.*                                                  -/var/log/maillog    邮件的所有信息存放在/var/log/maillog;-符号表示是使用异步的方式记录, 因为日志一般会比较大
# Log cron stuff
cron.*                                                  /var/log/cron    计划任务有关的信息存放在/var/log/cron
# Everybody gets emergency messages    每个人都会收到紧急信息
*.emerg                          *    记录所有的大于等于emerg级别信息, 以wall方式发送给每个登录到系统的人,*代表所有在线用户
# Save news errors of level crit and higher in a special file.
uucp,news.crit                                          /var/log/spooler    记录uucp,news.crit等存放在/var/log/spooler
# Save boot messages also to boot.log     启动的相关信息记录在/var/log/boot.log
local7.*                                                /var/log/boot.log
# ### begin forwarding rule ###  转发规则
# The statement between the begin … end define a SINGLE forwarding    再begin到end之间的语句定义了一个转发规则
# rule. They belong together, do NOT split them. If you create multiple    转发规则不要分开。如果您创建多个转发规则,请重复整个块!
# forwarding rules, duplicate the whole block!
# Remote Logging (we use TCP for reliable delivery)    如果远程日志记录(推荐使用TCP方式,因为它能可靠传送)
#
# An on-disk queue is created for this action. If the remote host is
# down, messages are spooled to disk and sent when it is up again.    为此操作创建一个磁盘队列。 如果远程主机关闭,消息将被假脱机到磁盘,并在重新启动时发送。
#$WorkDirectory /var/spppl/rsyslog # 在哪里放置假脱机文件
#$ActionQueueFileName fwdRule1 # 假脱机文件的唯一名称前缀
#$ActionQueueMaxDiskSpace 1g   # 1GB空间限制(尽可能多使用)
#$ActionQueueSaveOnShutdown on # 将消息保存到关机时的磁盘
#$ActionQueueType LinkedList   # 异步运行
#$ActionResumeRetryCount -1    # 如果主机关闭,则无限重试
#格式: 主机名/IP:端口。举例:192.168.0.1:514,(端口是可选的)
#*.* @@remote-host:514                    # @@表示通过tcp协议发送  @表示通过udp进行转发
# ### end of the forwarding rule ###

 

转载请注明:零五宝典 » Linux rsyslog学习教程使用方法(2)-配置文件详解