在 Debian 里“开启日志记录”通常不是某个单一开关,而是先确认用哪个日志系统,再确保服务在跑、配置正确。下面按最常见情况说明。
现代 Debian(8+)默认用 systemd journal,很多日志已经自动记录了。
systemctl status systemd-journald
如果没跑:
systemctl start systemd-journald
systemctl enable systemd-journald
journalctl
journalctl -xe
journalctl -u nginx
默认可能只在内存中。
编辑:
sudo nano /etc/systemd/journald.conf
修改:
Storage=persistent
然后:
sudo systemctl restart systemd-journald
如果你想用 /var/log/messages、/var/log/syslog 这类文件:
sudo apt update
sudo apt install rsyslog
sudo systemctl enable --now rsyslog
/var/log/syslog
/var/log/auth.log
/var/log/kern.log
例如 Nginx:
sudo nano /etc/nginx/nginx.conf
确保:
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
重启:
sudo systemctl restart nginx
df -h如果你能说清楚:
我可以给你更精确的配置。