Retry opening file instead of just crashing
With --real-time option I've passed an access.log file which is log-rotated. When rotating happened, this is what I got:
Fatal error has occurred
Error occurred at: src/goaccess.c - perform_tail_follow - 845
Unable to read the specified log file '/var/log/apache2/access.log.1'. No such file or directory
Version is: GoAccess - version 1.7 - Jan 4 2023 18:36:47
Should I use tail -F instead ?
What does your Logrotate configuration for the Apache logs look like? Feel free to post it here. GoAccess should be able to handle it, but it depends on how Logrotate is managing the logs, whether it's using copytruncate, renaming, etc. Also, consider upgrading to the latest version, as multiple bugs have been fixed since then.
This is the logrotate configuration for apache logs:
/var/log/apache2/*.log {
daily
missingok
rotate 14
compress
delaycompress
notifempty
create 640 root adm
sharedscripts
prerotate
if [ -d /etc/logrotate.d/httpd-prerotate ]; then
run-parts /etc/logrotate.d/httpd-prerotate
fi
endscript
postrotate
if pgrep -f ^/usr/sbin/apache2 > /dev/null; then
invoke-rc.d apache2 reload 2>&1 | logger -t apache2.logrotate
fi
endscript
}
I have no httpd-prerotate
Looks like the error happens because the rotated file (access.log.1) either gets compressed or deleted. It could also be a timing issue—logrotate renames the file and creates a new one, but before everything settles, /var/log/apache2/access.log.1.gz appears. Try running a manual rotation to see exactly what's going on.