在 Debian(以及大多数 Linux 发行版)中,日志格式取决于使用的日志系统。Debian 主要使用以下几种日志机制:
/var/log/syslog/var/log/auth.log/var/log/kern.log/var/log/dpkg.logJun 25 10:32:14 debian sshd[1234]: Accepted password for root from 192.168.1.10 port 22 ssh2
| 字段 | 说明 |
|---|---|
Jun 25 10:32:14 |
时间戳(月 日 时:分:秒) |
debian |
主机名 |
sshd[1234] |
服务名[进程ID] |
Accepted password... |
日志内容 |
cat /var/log/syslogtail -f /var/log/sysloggrep sshd /var/log/auth.logDebian 8+ 默认使用 systemd-journald
journalctl
journalctl -u ssh.service
journalctl -p err
Jun 25 10:32:14 debian sshd[1234]: Accepted password for root from 192.168.1.10
journalctl -o json
journalctl -o json-pretty
示例:
{
"__REALTIME_TIMESTAMP": "1624597934000000",
"PRIORITY": "6",
"SYSLOG_IDENTIFIER": "sshd",
"MESSAGE": "Accepted password for root"
}
✅ 适合脚本解析(Python / jq)
journalctl -o json | jq '.MESSAGE'
<34>1 2024-06-25T10:32:14Z debian sshd 1234 ID1 - message
| 场景 | 推荐方式 |
|---|---|
| 人工排查 | tail / journalctl |
| 脚本分析 | journalctl -o json |
| 集中日志 | rsyslog + ELK / Loki |
如果你有:
可以直接发出来,我可以帮你写解析规则或脚本。