syslog日志是系統日志的一種,可以存放在本地也可以發送到syslog日志服務器,
但是syslog日志由於的格式不統一,在日常工作中審計syslog日志是一種很麻煩的
事情。不過在2001出現了一份關於syslog標准的協議(建議)。
生成發送日志的叫做:Device
轉發的叫做:Relay(可以作為Device或Coolector)
接收的叫做:Collector
傳輸標准使用UDP,消息大小小於1024個字節,端口使用514
PS:只是建議。
syslog日志可以分為三部分:
4.1 syslog Message Parts The full format of a syslog message seen on the wire has three discernable parts. The first part is called the PRI, the second part is the HEADER, and the third part is the MSG. The total length of the packet MUST be 1024 bytes or less. There is no minimum length of the syslog message although sending a syslog packet with no contents is worthless and SHOULD NOT be transmitted.
標准格式:<23>Oct 9 23:33:20 192.168.0.1 ssh[1787]: Accepted publickey for root from.
PRF部分
Numerical Facility Code 0 kernel messages 內核信息; 1 user-level messages 用戶進程信息; 2 mail system 電子郵件相關信息; 3 system daemons 后台進程相關信息; 4 security/authorization messages (note 1)
5 messages generated internally by syslogd 系統日志信息
6 line printer subsystem 打印服務相關信息。
7 network news subsystem 新聞組服務器信息
8 UUCP subsystemuucp 生成的信息
9 clock daemon (note 2) 時鍾守護進程
10 security/authorization messages (note 1) 安全授權信息
11 FTP daemon
12 NTP subsystem 子進程
13 log audit (note 1) 日志審核
14 log alert (note 1)日志警報
15 clock daemon (note 2)
16 local use 0 (local0)本地用戶信息
17 local use 1 (local1)本地用戶信息
18 local use 2 (local2)本地用戶信息
19 local use 3 (local3)本地用戶信息
20 local use 4 (local4)本地用戶信息
21 local use 5 (local5)本地用戶信息
22 local use 6 (local6)本地用戶信息
23 local use 7 (local7)本地用戶信息
Table 1. syslog Message Facilities Note 1 - Various operating systems have been found to utilize Facilities 4, 10, 13 and 14 for security/authorization, audit, and alert messages which seem to be similar. Note 2 - Various operating systems have been found to utilize both Facilities 9 and 15 for clock (cron/at) messages. Each message Priority also has a decimal Severity level indicator. These are described in the following table along with their numerical values. Numerical Severity Code 0 Emergency: system is unusable 緊急狀態:系統無法使用 1 Alert: action must be taken immediately 警報:必須立即采取行動 2 Critical: critical conditions 臨界:臨界條件 3 Error: error conditions 錯誤:錯誤條件 4 Warning: warning conditions 警告:警告條件 5 Notice: normal but significant condition 通知:正常但重要的條件 6 Informational: informational messages 信息:信息消息 7 Debug: debug-level messages 調試:調試級別消息
Table 2. syslog Message Severities
HEADER部分(可選)
包括時間和HOST(主機或IP)
時間
格式為:MM dd hh:mm:ss
用數字表示
其中月MM為英文縮寫:Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec
有些長期日志可能會增加年字段。
HOST
主機或IP,無域名。
MSG部分
包括TAG:Content
TAG(可選):表示進程名及其進程號;格式:p[343]或p-343
Content:表示應用程序的自定義信息。
這是對syslog日志格式的簡單了解,為以后的日志審計提供基礎