
I have Apache running on my system for web development with php. Apache writes to an error.log file unique for the specific web site that I am working on. During debugging the log file grows, and I like to clear it every now and then. I had to change ownership of the file to me. I five read/write to everyone. But when I truncate the file and save, Apache no longer writes to it. The Apache error logs do not indicate a problem. I restart Apache and all is good again. But this is a nuisance. Is there a way to avoid this nuisance? Thanks -- Stephen

logrotate is your friend. A well configured logrotate will get around most of those problems. On 04/04/2016 06:01 PM, Stephen wrote:
I have Apache running on my system for web development with php.
Apache writes to an error.log file unique for the specific web site that I am working on.
During debugging the log file grows, and I like to clear it every now and then.
I had to change ownership of the file to me. I five read/write to everyone.
But when I truncate the file and save, Apache no longer writes to it. The Apache error logs do not indicate a problem.
I restart Apache and all is good again. But this is a nuisance.
Is there a way to avoid this nuisance?
Thanks
-- Alvin Starr || voice: (905)513-7688 Netvel Inc. || Cell: (416)806-0133 alvin@netvel.net ||

Thank you for your idea. But running logrotate on an "as needed" basis is just as much a nuisance as restarting apache. During a debugging session, I may want to clear the error.log file every 10 minutes -- Stephen On 16-04-04 06:08 PM, Alvin Starr wrote:
logrotate is your friend.
A well configured logrotate will get around most of those problems.
On 04/04/2016 06:01 PM, Stephen wrote:
I have Apache running on my system for web development with php.
Apache writes to an error.log file unique for the specific web site that I am working on.
During debugging the log file grows, and I like to clear it every now and then.
I had to change ownership of the file to me. I five read/write to everyone.
But when I truncate the file and save, Apache no longer writes to it. The Apache error logs do not indicate a problem.
I restart Apache and all is good again. But this is a nuisance.
Is there a way to avoid this nuisance?
Thanks

you could setup logrotate to run every 10 minutes. If you reload apache (as opposed to restarting) I think it will reconnect to the new logfile. This may help: https://httpd.apache.org/docs/trunk/programs/rotatelogs.html Possibly its time to think of some other logging solution like logstash. On 04/04/2016 06:43 PM, Stephen wrote:
Thank you for your idea.
But running logrotate on an "as needed" basis is just as much a nuisance as restarting apache.
During a debugging session, I may want to clear the error.log file every 10 minutes
-- Alvin Starr || voice: (905)513-7688 Netvel Inc. || Cell: (416)806-0133 alvin@netvel.net ||

On Mon, Apr 04, 2016 at 06:01:18PM -0400, Stephen wrote:
I have Apache running on my system for web development with php.
Apache writes to an error.log file unique for the specific web site that I am working on.
During debugging the log file grows, and I like to clear it every now and then.
I had to change ownership of the file to me. I five read/write to everyone.
But when I truncate the file and save, Apache no longer writes to it. The Apache error logs do not indicate a problem.
I restart Apache and all is good again. But this is a nuisance.
Is there a way to avoid this nuisance?
Apache has the file open with the current seek location known. The fact you truncate the file is not apache's problem and it will keep writing where it got to. If you want to do that, you have to signal to it that you want it to reopen the log file, which usually a reload (often sending SIGHUP) will do. -- Len Sorensen
participants (3)
-
Alvin Starr
-
Lennart Sorensen
-
Stephen