Debian 系统上的 syslog 格式通常遵循 RFC 3164(BSD syslog) 规范,但在较新版本中也支持 RFC 5424。下面按常见情况说明。
这是 Debian 默认 /var/log/syslog 中最常见的格式:
<优先级> 时间戳 主机名 进程[PID]: 消息内容
<34>Jan 21 10:23:01 debian sshd[1234]: Accepted password for user1 from 192.168.1.10 port 22
| 字段 | 说明 |
|---|---|
<34> |
优先级(Priority),含 facility + severity |
Jan 21 10:23:01 |
时间戳(无年份) |
debian |
主机名 |
sshd[1234] |
进程名和 PID |
Accepted password ... |
日志消息 |
优先级 = Facility × 8 + Severity
| 值 | 含义 |
|---|---|
| 0 | emergency |
| 1 | alert |
| 2 | critical |
| 3 | error |
| 4 | warning |
| 5 | notice |
| 6 | informational |
| 7 | debug |
例如:
<34> = 4 (auth) × 8 + 2 (critical)
Debian 默认使用 rsyslog,日志格式仍为传统 syslog。
配置文件:
/etc/rsyslog.conf
/etc/rsyslog.d/*.conf
日志位置:
/var/log/syslog
/var/log/auth.log
/var/log/kern.log
开启后格式为:
<优先级>1 时间戳 主机名 应用名 进程ID 消息ID 结构化数据 消息
<34>1 2026-01-21T10:23:01.123Z debian sshd 1234 - - Accepted password
特点:
Debian 使用 systemd 后,日志还可通过 journald 查看:
journalctl
journal 日志是 二进制格式,包含:
但 journalctl -o short 可输出类似 syslog 的文本格式。
✅ Debian 默认 syslog 格式(rsyslog):
<优先级> 时间戳 主机名 进程[PID]: 消息
✅ 实际使用的是 RFC 3164
✅ 可通过 rsyslog 配置切换为 RFC 5424
✅ systemd journal 使用独立二进制格式
如果你需要:
可以继续问我。