PDA

View Full Version : Error.log rotation


Alex1
14th July 2009, 08:31
Hello

can you add the rotation of vhosts' error.log in the next version? sometimes it can be very big causing problems in user's quota.

Bookworm
29th August 2009, 15:29
It looks like what could be done, at least as a quick and dirty fix, is modify the /usr/local/ispconfig/server/cron_daily.php file as follows.

Take the logrotation section and duplicate the access log entries with error log entries.

################################################## ################################################## ###
// Manage and compress web logfiles
################################################## ################################################## ###

$sql = "SELECT domain_id, domain, document_root FROM web_domain WHERE server_id = ".$conf["server_id"];
$records = $app->db->queryAllRecords($sql);
foreach($records as $rec) {
$yesterday = date("Ymd",time() - 86400);
$logfile = escapeshellcmd($rec["document_root"].'/log/'.$yesterday.'-access.log');
$errorfile = escapeshellcmd($rec["document_root"].'/log/'.$yesterday.'-error.log');
if(@is_file($logfile)) {
// Compress yesterdays logfile
exec("gzip -c $logfile > $logfile.gz");
unlink($logfile);
}
if(@is_file($errorfile)) {
// Compress yesterdays logfile
exec("gzip -c $errorfile > $errorfile.gz");
unlink($errorfile);
}

// delete logfiles after 7 days
$week_ago = date("Ymd",time() - 86400 * 7);
$logfile = escapeshellcmd($rec["document_root"].'/log/'.$week_ago.'-access.log.gz');
$errorfile = escapeshellcmd($rec["document_root"].'/log/'.$week_ago.'-error.log.gz');
if(@is_file($logfile)) {
unlink($logfile);
}
if(@is_file($errorfile)) {
unlink($errorfile);
}
}

#####

I haven't tried it yet - I just put it in myself - but it should work fine.

Keeper
27th March 2010, 12:14
I just updated to the latest ISPConfig3 and was wondering why it still does not have error log rotation?

Above script posted by Bookworm doesn't work by the way.

till
28th March 2010, 22:37
Please look at the roadmap.

http://bugtracker.ispconfig.org

I just updated to the latest ISPConfig3 and was wondering why it still does not have error log rotation?

Because nobody has written such a function yet. So feel free to write it and contribute the code to the ispconfig project if you miss a feature.

Keeper
29th March 2010, 07:31
If I could write it, I already would have.

I serve over 45 websites with ISPConfig, many of those currently have error.log over 200MB in size because there's no rotation. Going through each domain by hand is not really practical, though I've done it a few times.

My guess is that average error.log size could be around 100MB, which would mean nearly 5GB is taken by just error.logs.

abubin
30th March 2010, 12:17
this shouldn't be that hard to do. Just modify the codes from access logrotate script in cron_daily.php

Keeper
30th March 2010, 13:16
From what I can see ISPConfig plays around with symlinks for access log rotation. More than just cron_daily.php modification is needed for proper support in ISPConfig I'm afraid.

till
30th March 2010, 13:20
The symlinks are from vlogger and not ispconfig. But indeed, it might not be sufficient to rotate the files as the error.log is in use by the apache process, so it might be nescessary to implement error logging trough vlogger as well.

abubin
2nd April 2010, 08:08
--wrong section----