rsyslog配置文件詳解(rsyslog.conf)


# 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 ###
延伸知識點:
1. 假脫機
在信息學中,假脫機(外部設備聯機並行操作,SPOOL,Simultaneous Peripheral Operations On-line)是一種數據緩沖,指傳輸數據的過程中,將數據存放在臨時工作區中。其它程序可以在之后的任意時間點對其存取。通常英語動詞spool可以指儲存設備的行為,具體表現為物理意義上的纏或卷,就比如說磁帶機。最常見的假脫機的應用是打印緩存,即把打印任務加入到隊列。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM