Reputation: 51
I've had a problem with some Apache web server error logs.
I have a virtually hosted website scotthermmann.loc on my computer. After I manually clear an error log, using
sudo cat /dev/null > scotthermmann.loc-error_log
or by opening the file in emacs & deleting all content, errors no longer get logged to the file. I've tried using
sudo apachectl restart
to solve the problem, but it doesn't solve it. Logging out & back in doesn't solve it either. What does solve it is restarting the computer, but I don't want to do that after every time I clear an error log.
This isn't the case for every website I host. I have another website barefootfool.loc. After I clear that error log, I don't have any problems.
Both virtual sites have essentially the same setup in the httpd-vhosts.conf file. For scottherrmann.loc:
<VirtualHost *:80>
DocumentRoot "/Users/dan/Sites/scottherrmann.com"
ServerName scottherrmann.loc
ServerAlias www.scottherrmann.loc
ErrorLog "/private/var/log/apache2/scottherrmann.loc-error_log"
CustomLog "/private/var/log/apache2/scottherrmann.loc-access_log"
<Directory "/Users/dan/Sites/scottherrmann.com">
Options Indexes FollowSymLinks
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>
</VirtualHost>
And for barefootfool.loc:
<VirtualHost *:80>
DocumentRoot "/Users/dan/Sites/barefootfool.com"
ServerName barefootfool.loc
ServerAlias www.barefootfool.loc
ErrorLog "/private/var/log/apache2/barefootfool.loc-error_log"
CustomLog "/private/var/log/apache2/barefootfool.loc-access_log"
<Directory "/Users/dan/Sites/barefootfool.com">
Options Indexes FollowSymLinks
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>
</VirtualHost>
Does anyone have an idea what could be causing the problem?
Upvotes: 5
Views: 19149
Reputation: 5041
I just had this it was because I inadvisably deleted the /var/log/httpd/error_log file and then touched a new log file.
service httpd restart
cleared the problem . next time I'll truncate the error_log with
:>error_log
Upvotes: 8
Reputation: 23381
Probably it is because you run the tomcat with the user apachectl
and when you clear the log file with the command sudo cat /dev/null > scotthermmann.loc-error_log
the user that execute this command take the ownership of the file then the user apachectl
can't write on it anymore. Try to run the cleanup command as this:
sudo apachectl cat /dev/null > scotthermmann.loc-error_log
Upvotes: 0