How can Apache access logs be rotated daily for Webtrends reporting?

brundle

Verified User
Joined
Apr 16, 2004
Messages
32
Location
Portland, OR
How can I get DA to rotate Apache access logs daily instead of monthly or at 100mb?

With daily rotated logs Webtrends can access the logs via a user ftp account and build daily reports.
 
Admin Level > Administrator Settings

You can set the Apache Log Rotate Size. Specified in megabytes. The default is 100mb so it should be rotating them every 100mb already. (+/- some since it doesn't know how big they are until the tally is run at the end of the day)
 
But how can it be forced to rotate daily regardless of size. Many of the sites haven't reach 100 mb log files sizes and it's been months.
 
haha! grammer grammer

You could modify the crontab that runs it every 24 hours to rotate the logs after it has run its tally. I think the logrotate setting in DA is run through DA when the tally cron is run because there aren't any logroates in my crontab for that. So it shouldn't cause a problem I would think.
 
So you mean use logrotate to rotate the logs after DA has had a chance to parse them?

Is there a way to update DA's daily task list to do this?
 
Last edited:
The problem is, now how to get logrotate to know about the domains dynamically.

With many domains logrotate would have to rotate a domainname.log file and put it into the domains directory - I assume a manual entry would be necessary for each domain so logrotate would know about the domain names and corresponding directory names.

I need to get the log files to the domains directories so that Webtrends can FTP to the dirs, copy the logs and parse them for daily reports.

Even if I rigged an FTP account to have Webtrends grab logs from the /var/log/httpd dir there is still the chance that a log would reach 100meg, get rotated, and then Webtrends would be missing data...
 
I believe you can identify a prerotate script which would run before the logs would rotate. The script could either push the previous logs to another system or directory, or rename them.

Jeff
 
You could even have cron execute a php script which would use the unix commands to get a list of all domains as a variable. Then you can have it do the dirty work without having to add all the domains manually to your script.
 
OK, so I ended up using cronolog.

I added a line like this to the custom apache config in DA for each domain/site I needed FTP access to the logs for WebTrends.

CustomLog "|/usr/local/sbin/cronolog /home/username/domains/domainname/logs/domainname.%y%m%d.access.log" combined
 
Back
Top