温馨提示×

debian syslog是什么格式

小樊
53
2026-09-17 20:11:05
栏目: 智能运维

Debian 中的 syslog 日志格式,通常指的是 syslog 协议(RFC 3164 / RFC 5424) 生成的日志行格式,以及 Debian 默认使用 rsyslog 时的具体表现。


一、传统 syslog 格式(RFC 3164,Debian 常见)

这是 Debian 最经典、最常见的格式:

<优先级> 时间戳 主机名 进程[PID]: 消息内容

示例

Mar  5 10:22:31 debian sshd[1234]: Accepted password for root from 192.168.1.10 port 22

各字段说明

  1. 时间戳
    • 格式:MMM DD HH:MM:SS
    • 例:Mar 5 10:22:31
  2. 主机名
    • 产生日志的主机名
  3. 进程名 [PID]
    • sshd[1234]
  4. 消息内容
    • 具体日志信息

二、优先级(Priority)

格式开头的 <数字> 是优先级(可省略):

PRIORITY = FACILITY * 8 + SEVERITY

常见等级(Severity)

等级 含义
0 emerg
1 alert
2 crit
3 err
4 warning
5 notice
6 info
7 debug

例如:

<34> => facility=4 (auth), severity=2 (crit)

三、RFC 5424 格式(现代 syslog)

部分系统(或 rsyslog 配置)使用:

<134>1 2026-03-05T10:22:31.123Z debian sshd 1234 ID123 - Accepted password

结构:

<pri>VERSION TIMESTAMP HOST APP PID MSGID STRUCTURED-DATA MSG

四、Debian 默认日志位置

  • /var/log/syslog
  • /var/log/messages
  • /var/log/auth.log

五、Debian 使用的 syslog 实现

  • rsyslog(默认)
  • systemd-journald
    • journalctl 查看
    • 二进制格式,不是纯文本 syslog

六、简单总结

✅ Debian syslog 常见格式:

时间戳 主机 进程[PID]: 日志内容

如果你愿意,我可以:

  • 给你 rsyslog 配置示例
  • 帮你 解析某一行 syslog
  • 对比 Debian vs CentOS 日志格式

0 踩