Forum Moderators: travelin cat

Message Too Old, No Replies

How to Automated log rolling for Apache2?

         

afterhours

2:44 pm on Jan 12, 2005 (gmt 0)

10+ Year Member



OK --- this should be really really easy to google, but I've had little success, so I turn to the masters.

Am moving beyond my older server technology (Webstar 4 / OS 9) to Apache2/PHP/MySQL. Feel like a newbie all over again :) Would someone kindly tell me what their preferred tools are for managing log rolling in Apache2? I am using 10.3.7 and the ServerLogistics packages as a starting point to learn. Am very comfortable configuring the httpd with BBEdit. Currently am logging in just one master log. Eventually will likely use the log splitting in the VH arguments in httpd file, but for now:

Would like to understand the following:

How to roll the Apache2 logs (both visitation and error) on a chronological basis (every month, week or day).

How to move/archive/rename the logs automatically for storage.

How Apache is managed during all this (are Apache processes quit, logs rolled, then Apache restarted, or is there some other method?)

Many thanks in advance.

moltar

2:50 pm on Jan 12, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WW afterhours!

Apache log rotation is done via external programs/scripts.

Basically you need to write a script that will:

  • Stop apache
  • Copy log file to a backup log file
  • Create a new, empty log file
  • Start apache

I think there should be millions of written scripts for this purpose, it seems like a trivial problem.

Hanu

3:44 pm on Jan 12, 2005 (gmt 0)

10+ Year Member



Apache documentation on log rotation [httpd.apache.org]

Use cron to run the script periodically. Type

man cron
to find out more.

OR:

If you're talking about MacOS: logrotate is a professional tool for log rotation. A version for MacOS can be found at Fink [fink.sourceforge.net]

ALSO:

O'Reilly MacOS hacks [oreillynet.com]

afterhours

4:25 pm on Jan 12, 2005 (gmt 0)

10+ Year Member



Moltar and Hanu: thanks -- Like you folks, I would have thought the web would be thick with such scripts (examples and discussion), but as I mentioned in my post, it really isn't. Wow! So I'll have to dig into the man for cron and figure out what I need to do. Shouldn't be much more of a headache than AppleScript. I am surprised at the lack of info on this available, even from the Mac Server books. I must not be using the right search terms (like 'Macintosh Apache2 Log Rolling').

As for Fink -- I've heard about Fink quite a bit. Visiting their website, it is difficult at first to figure out what Fink is. Is it an application, an open-source community porting other applications, or what (the latter). Their web offerings tease with potential solutions for my log rolling quest, but nothing there fits the bill. Log analysis I already take care of, but rolling is a seemingly simple question to which there is no obvious answers out there.

afterhours

4:44 pm on Jan 12, 2005 (gmt 0)

10+ Year Member



As I dig deeper in the man and read the Apache docs, I think using piped logs makes the most sense (over the alternative of quitting Apache, moving/renaming the logs/ restarting Apache) for my needs. Now I need to find some examples of this piping technique.

I would think there are oodles of solutions where one can append a date/time stamp or some other custom name to each log when archiving (to avoid over-writing the last archive with the next archive. Will need to dig deeper. All hints appreciated.

BjarneDM

1:40 am on Jan 14, 2005 (gmt 0)

10+ Year Member



well, a quick google - [google.com...] - gave these two on the first page of results:
[builder.com.com...]
[theprecipice.org...]

and futher:
[cronolog.org...]
[localhost...]
[builder.com.com...]
[builder.com.com...]