Error.log rotation

Discussion in 'Feature Requests' started by Alex1, Jul 14, 2009.

  1. Alex1

    Alex1 New Member

    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.
     
  2. Bookworm

    Bookworm New Member

    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.
     
  3. Keeper

    Keeper New Member

    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.
     
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    Please look at the roadmap.

    http://bugtracker.ispconfig.org

    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.
     
  5. Keeper

    Keeper New Member

    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.
     
  6. abubin

    abubin New Member

    this shouldn't be that hard to do. Just modify the codes from access logrotate script in cron_daily.php
     
  7. Keeper

    Keeper New Member

    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.
     
  8. till

    till Super Moderator Staff Member ISPConfig Developer

    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.
     
  9. abubin

    abubin New Member

    --wrong section----
     
    Last edited: Apr 2, 2010

Share This Page