Debian 系统日志管理实操指南
术语澄清与总体架构
查看与检索日志
日志轮转与保留策略
/var/log/syslog
/var/log/auth.log
/var/log/kern.log {
daily
rotate 7
compress
missingok
notifempty
create 640 root adm
postrotate
systemctl reload rsyslog >/dev/null 2>&1 || true
endscript
}
集中化与远程日志
# 将本地所有日志以 UDP 发送到 192.0.2.10:514
*.* @192.0.2.10:514
# 如需加密传输,使用 TCP + TLS(需证书配置)
# *.* @@192.0.2.10:514
应用配置后执行:sudo systemctl restart rsyslogsource s_local { system(); };
destination d_remote { syslog("192.0.2.10" port(514)); };
log { source(s_local); destination(d_remote); };
应用配置后执行:sudo systemctl restart syslog-ng日志分析与告警实践