/etc/rsyslog.conf文件详解

Linux系统自动的log功能,目前由rsyslog服务代管,应该说rsyslog 是syslog 的升级版。

[root@FNSHB109 ~]# cat /etc/rsyslog.conf

rsyslog configuration file

MODULES

#加载模块列表

The imjournal module bellow is now used as a message source instead of imuxsock.

$ModLoad imuxsock # provides support for local system logging (e.g. via logger command)
提供对本地系统日志的支持
KaTeX parse error: Expected 'EOF', got '#' at position 19: …Load imjournal #̲ provides acces…ModLoad imklog # reads kernel messages (the same are read from journald)
读取内核消息
#$ModLoad immark # provides --MARK-- message capability
提供–MARK–消息功能

Provides UDP syslog reception

#KaTeX parse error: Expected 'EOF', got '#' at position 15: ModLoad imudp #̲UDPServerRun 514 允许514端口接收使用UDP协议转发过来的日志

Provides TCP syslog reception

#KaTeX parse error: Expected 'EOF', got '#' at position 15: ModLoad imtcp #̲InputTCPServerRun 514允许514端口接收使用TCP协议转发过来的日志

GLOBAL DIRECTIVES

#全局指令,

Where to place auxiliary files

$WorkDirectory /var/lib/rsyslog

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/

$IncludeConfig /etc/rsyslog.d/*.conf

Turn off message reception via local log socket;

local messages are retrieved through imjournal now.

$OmitLocalLogging on

File to store the position in the journal

$IMJournalStateFile imjournal.state

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 :omusrmsg:
记录所有的大于等于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
uucp –unix to unix copy, unix主机之间相关的通讯,news –新闻组

Save boot messages also to boot.log

local7.* /var/log/boot.log
启动的相关信息

begin forwarding rule

转发规则

The statement between the begin … end define a SINGLE forwarding

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)

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.

#KaTeX parse error: Expected 'EOF', got '#' at position 30: …eName fwdRule1 #̲ unique name pr…ActionQueueMaxDiskSpace 1g # 1gb space limit (use as much as possible)
#KaTeX parse error: Expected 'EOF', got '#' at position 30: …eOnShutdown on #̲ save messages …ActionQueueType LinkedList # run asynchronously
#$ActionResumeRetryCount -1 # infinite retries if host is down

remote host is: name/ip:port, e.g. 192.168.0.1:514, port optional

#. @@remote-host:514
@@表示通过tcp协议发送,使用TCP协议转发到remote-host的514(默认)端口
@表示通过udp进行转发

### end of the forwarding rule

————————————————
版权声明:本文为CSDN博主「zhouzhouruirui」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/zhouzhouruirui/article/details/84378465

你可能感兴趣的:(/etc/rsyslog.conf文件详解)