You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by David Wong <am...@starhub.net.sg> on 2004/12/25 13:46:27 UTC

[users@httpd] rotating log files

Hi guys,
 
I am quite new to the HTTP server. I was making some efforts to
understand how to do log files rotation. I read the documentation on
rotating log files. 
There is an example of doing it this way
 
mv access_log access_log.old
mv error_log error_log.old
apachectl graceful
sleep 600
gzip access_log.old error_log.old
 
Do I write this in the configuration file or is it a separate script I
have to write?
Regards,
david

Re: [users@httpd] rotating log files

Posted by Eric Ladner <er...@gmail.com>.
On Sat, 25 Dec 2004 14:01:41 -0500, Sean T Allen <se...@usaherbals.com> wrote:
> You can send a HUP signal to apache which will restart writing the files...
> 

That's what "apachectl graceful" does.

-- 
Eric Ladner

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] rotating log files

Posted by Sean T Allen <se...@usaherbals.com>.
You can send a HUP signal to apache which will restart writing the files...

if you use logrotate something like:

/var/log/httpd/access.log
{
        sharedscripts
        size=100M
        prerotate
# any prerotate here
# we run a stat update here...
        endscript
        postrotate
                kill -HUP `cat /var/run/httpd.pid`
        endscript
}

adjust to your taste...


Shashank Bhide wrote:

>
>>> mv access_log access_log.old
>>> mv error_log error_log.old
>>> apachectl graceful
>>> sleep 600
>>> gzip access_log.old error_log.old 
>>
>
> I was curious, doesn't apache actively write to the log files? So do 
> we need to stop apache before, say move the files? (Stop the network 
> when we move the files, may be?)
>     Would the graceful start create new access and error log files, 
> since they were non existant after the move?
>
> Thanks,
> Shashank
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server 
> Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>   "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>


Re: [users@httpd] rotating log files

Posted by Eric Ladner <er...@gmail.com>.
That's what the "apachectl graceful" does.  


On Sat, 25 Dec 2004 11:13:55 -0600, Shashank Bhide
<sh...@biochem.okstate.edu> wrote:
> 
> >>mv access_log access_log.old
> >> mv error_log error_log.old
> >> apachectl graceful
> >> sleep 600
> >> gzip access_log.old error_log.old
> 
> I was curious, doesn't apache actively write to the log files? So do we
> need to stop apache before, say move the files? (Stop the network when
> we move the files, may be?)
>         Would the graceful start create new access and error log files, since
> they were non existant after the move?
> 
> Thanks,
> Shashank
>
-- 
Eric Ladner

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] rotating log files

Posted by Shashank Bhide <sh...@biochem.okstate.edu>.
>>mv access_log access_log.old
>> mv error_log error_log.old
>> apachectl graceful
>> sleep 600
>> gzip access_log.old error_log.old 

I was curious, doesn't apache actively write to the log files? So do we 
need to stop apache before, say move the files? (Stop the network when 
we move the files, may be?)
	Would the graceful start create new access and error log files, since 
they were non existant after the move?

Thanks,
Shashank

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] rotating log files

Posted by Eric Ladner <er...@gmail.com>.
It would be a separate shell script that you'd run every night or on
Sunday or whatever...

If you want something where you can save logs for late processing for
a greater length of time:

dt=$(date '+%Y%m%d')
mv access_log access_log.$dt
mv error_log error_log.$dt
apachectl graceful
sleep 600
gzip access_log.$dt error_log.$dt

This way, you'll end up with date stamped log files.

On Sat, 25 Dec 2004 20:46:27 +0800, David Wong <am...@starhub.net.sg> wrote:
>  
>  
> 
> Hi guys, 
> 
>   
> 
> I am quite new to the HTTP server. I was making some efforts to understand
> how to do log files rotation. I read the documentation on rotating log
> files. 
> 
> There is an example of doing it this way 
> 
>   
> 
> mv access_log access_log.old
>  mv error_log error_log.old
>  apachectl graceful
>  sleep 600
>  gzip access_log.old error_log.old 
> 
>   
> 
> Do I write this in the configuration file or is it a separate script I have
> to write? 
> 
> Regards, 
> 
> david 


-- 
Eric Ladner

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] rotating log files

Posted by hutuworm <hu...@gmail.com>.
Check cronolog at: http://www.cronolog.org/

cronolog is a simple filter program that reads log file entries from
standard input and writes each entry to the output file specified by a
filename template and the current date and time. When the expanded
filename changes, the current file is closed and a new one opened.
cronolog is intended to be used in conjunction with a Web server, such
as Apache, to split the access log into daily or monthly logs. For
example the Apache configuration directives:

TransferLog "|/usr/sbin/cronolog /web/logs/%Y/%m/%d/access.log"
ErrorLog    "|/usr/sbin/cronolog /web/logs/%Y/%m/%d/errors.log"

would instruct Apache to pipe its access and error log messages into
separate copies of cronolog, which would create new log files each day
in a directory hierarchy structured by date, i.e. on 31 December 2002
messages would be written to

/web/logs/2002/12/31/access.log
/web/logs/2002/12/31/errors.log

after midnight the files

/web/logs/2003/01/01/access.log
/web/logs/2003/01/01/errors.log

would be used, with the directories 2003, 2003/01 and 2003/01/01 being
created if they did not already exist. More detail to come...


On Sat, 25 Dec 2004 20:46:27 +0800, David Wong <am...@starhub.net.sg> wrote:
>  
>  
> 
> Hi guys, 
> 
>   
> 
> I am quite new to the HTTP server. I was making some efforts to understand
> how to do log files rotation. I read the documentation on rotating log
> files. 
> 
> There is an example of doing it this way 
> 
>   
> 
> mv access_log access_log.old
>  mv error_log error_log.old
>  apachectl graceful
>  sleep 600
>  gzip access_log.old error_log.old 
> 
>   
> 
> Do I write this in the configuration file or is it a separate script I have
> to write? 
> 
> Regards, 
> 
> david 


-- 
In doG We Trust
http://www.hutuworm.org

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org