在 Debian 上“丢失 Apache 日志”( access.log / error.log 不见了或不再更新)通常由以下几类原因造成,按出现频率从高到低说明,并给出排查方法。
Debian 默认用 logrotate 管理 Apache 日志:
/etc/logrotate.d/apache2access.log.1)logrotate 执行了 mv,但 Apache 没收到 reload 信号copytruncate 以外的方式,但 Apache 没重启ls -l /var/log/apache2/
ls -l /var/log/apache2/*.1
systemctl reload apache2
不同虚拟主机可能指定了不同日志路径:
CustomLog ${APACHE_LOG_DIR}/other-access.log combined
ErrorLog ${APACHE_LOG_DIR}/other-error.log
grep -R "CustomLog\|ErrorLog" /etc/apache2/
如果日志目录权限错误:
ls -ld /var/log/apache2
ps aux | grep apache
Apache 通常以 www-data 运行。
chown -R root:adm /var/log/apache2
chmod 750 /var/log/apache2
LogLevel 设置过高(如 crit)log_config_moduleapache2ctl -M | grep log_config
df -h
df -i
即使磁盘有空间,inode 满也会导致日志无法写入。
systemctl status apache2
journalctl -u apache2
docker logsjournald、fluentd 等systemctl status apache2
ls -l /var/log/apache2
grep -R "ErrorLog|CustomLog" /etc/apache2
apache2ctl configtest
df -h; df -i
如果你能补充:
我可以更精确地判断原因。