rsyslog 配置 二

轉自:https://www.cnblogs.com/cherishry/p/6775163.html

rsyslog 配置 二

# rsyslog configuration file

# For more information see /usr/share/doc/rsyslog-*/rsyslog_conf.html

# If you experience problems, see http://www.rsyslog.com/doc/troubleshoot.html

#### 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)(提供對本地系統日誌的支持(例如經過記錄器命令))

$ModLoad imjournal         # provides access to the systemd journal(提供對systemd日誌的訪問)

#$ModLoad imklog         # reads kernel messages (the same are read from journald)(讀取內核消息(從日誌讀取相同的消息))

#$ModLoad immark          # provides --MARK-- message capability(提供--MARK--消息功能)

# Provides UDP syslog reception

#接收使用UDP 協議轉發過來的日誌

$ModLoad imudp

$UDPServerRun 514

# Provides TCP syslog reception

#接收使用TCP 協議轉發過來的日誌

#$ModLoad imtcp

#$InputTCPServerRun 514

#注意:兩個協議能夠同時監聽

#### GLOBAL DIRECTIVES ####

#定義日誌格式默認模板

# Where to place auxiliary files

$WorkDirectory /var/lib/rsyslog

# Use default timestamp format

$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat

$template myFormat,"%timestamp% %fromhost-ip% %msg%\n"                  #定義模板 $template tplname, string/list/subtree/plugin

$ActionFileDefaultTemplate myFormat                                     #默認使用myFormat模板

# 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

# Turn off message reception via local log socket;                                                   #經過本地日誌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.       #郵件的全部信息存放在/var/log/maillog; 這裏有一個-符號, 表示是使用異步的方式記錄, 由於日誌通常會比較大

mail.*                                                  -/var/log/maillog

# Log cron stuff                                                    #計劃任務有關的信息存放在/var/log/cron

cron.*                                                  /var/log/cron

# Everybody gets emergency messages            #記錄全部的大於等於emerg級別信息, 以wall方式發送給每一個登陸到系統的人

*.emerg                                                 :omusrmsg:*

# 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之間的語句定義了一個SINGLE轉發

# 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掉,消息被假脫機到磁盤,並在從新啓動時發送。

# down, messages are spooled to disk and sent when it is up again.

#$ActionQueueFileName fwdRule1 # unique name prefix for spool files                  #假脫機文件的惟一名稱前綴

#$ActionQueueMaxDiskSpace 1g   # 1gb space limit (use as much as possible)       #1gb空間限制(儘量多使用)

#$ActionQueueSaveOnShutdown on # save messages to disk on shutdown            #關閉時將消息保存到磁盤

#$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

*.*        @@localhost:5000                                                                                                 #@@表示經過tcp協議發送    @表示經過udp進行轉發

# ### end of the forwarding rule ###html

相關文章
相關標籤/搜索