The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

apache log rotation

Discussion in 'EasyApache' started by gordita, Aug 14, 2001.

  1. gordita

    gordita Well-Known Member

    Joined:
    Aug 14, 2001
    Messages:
    113
    Likes Received:
    0
    Trophy Points:
    16
    How can I configure the apache log rotation? I found no mention of them in /etc/logrotate.conf
     
  2. Brian Farkas

    Brian Farkas Well-Known Member

    Joined:
    Aug 12, 2001
    Messages:
    81
    Likes Received:
    0
    Trophy Points:
    6
    Edit this file:
    /etc/logrotate.d/apache

    Good luck,

    Brian Farkas
     
  3. gordita

    gordita Well-Known Member

    Joined:
    Aug 14, 2001
    Messages:
    113
    Likes Received:
    0
    Trophy Points:
    16
    I don\'t have that file :( This is a farily new server that really hasn\'t been modified much at all.

    My /etc/logrotate.conf contains:

    # see \"man logrotate\" for details
    # rotate log files weekly
    weekly

    # keep 4 weeks worth of backlogs
    rotate 4

    # send errors to root
    errors root

    # create new (empty) log files after rotating old ones
    create

    # uncomment this if you want your log files compressed
    #compress

    # RPM packages drop log rotation information into this directory
    include /etc/logrotate.d

    # no packages own lastlog or wtmp -- we\'ll rotate them here
    /var/log/wtmp {
    monthly
    create 0664 root utmp
    rotate 1
    }

    and my /etc/logrotate.d dir contains on these files:
    cron exim linuxconf mars-nwe.log mysql named samba syslog uucp

    I grep\'d through all these files to look for any reference to the /usr/local/apache/domlogs logs. Did something go freaky with my Cpanel installation? It sounds like most people have the /etc/logrotate.d/apache file.
     
  4. gordita

    gordita Well-Known Member

    Joined:
    Aug 14, 2001
    Messages:
    113
    Likes Received:
    0
    Trophy Points:
    16
    I guess maybe there is just something freaky about my box? Seems like most cpanel users have the /etc/logrotate.d/apache file
     
  5. Brian Farkas

    Brian Farkas Well-Known Member

    Joined:
    Aug 12, 2001
    Messages:
    81
    Likes Received:
    0
    Trophy Points:
    6
    If you wanted to create it, this is what we have in our file:
    /var/log/httpd/access_log {
    missingok
    postrotate
    /usr/bin/killall -HUP httpd 2> /dev/null || true
    endscript
    }

    /var/log/httpd/agent_log {
    missingok
    postrotate
    /usr/bin/killall -HUP httpd 2> /dev/null || true
    endscript
    }

    /var/log/httpd/error_log {
    missingok
    postrotate
    /usr/bin/killall -HUP httpd 2> /dev/null || true
    endscript
    }

    /var/log/httpd/referer_log {
    missingok
    postrotate
    /usr/bin/killall -HUP httpd 2> /dev/null || true
    endscript
    }

    --

    Good luck,

    Brian
     
  6. gordita

    gordita Well-Known Member

    Joined:
    Aug 14, 2001
    Messages:
    113
    Likes Received:
    0
    Trophy Points:
    16
    Thanks Brian, I\'ll give that a shot.
     
  7. gordita

    gordita Well-Known Member

    Joined:
    Aug 14, 2001
    Messages:
    113
    Likes Received:
    0
    Trophy Points:
    16
    I think I may have miscommunicated in my last message about this.

    I am trying to figure out to rotate the logs in /usr/local/apache/domlogs

    They are currently being rotated monthly and I guess that\'s just done internally with cpanel?
     
  8. Brian Farkas

    Brian Farkas Well-Known Member

    Joined:
    Aug 12, 2001
    Messages:
    81
    Likes Received:
    0
    Trophy Points:
    6
    You should be able to do this by editing the /etc/logrotate.d/apache file as well. Here\'s the steps to set up a custom log rotation on a domain...

    1. Edit the httpd.conf file for the domain to point to a directory within the customer\'s home directory. In this example we\'ll use /home/username/logs/. Note that this directory isn\'t web accessible, but the customer will be able to download log files from here.

    In other words, the httpd.conf entry should look like:
    CustomLog /home/username/logs/domain.com combined

    2. Restart httpd

    3. Add an entry that looks like this in the /etc/logrotate.d/apache file:

    /home/username/logs/domain.com {
    rotate 5
    daily
    compress
    }

    The above will rotate each log daily, and keep the log on the system for 5 rotations. You can find out about more options by running man logrotate from the command line. Good luck!

    Brian
     
  9. eva2000

    eva2000 Well-Known Member

    Joined:
    Aug 14, 2001
    Messages:
    322
    Likes Received:
    9
    Trophy Points:
    18
    Location:
    Brisbane, Australia
    cPanel Access Level:
    Root Administrator
    Twitter:
    [quote:45d760ec92]You should be able to do this by editing the /etc/logrotate.d/apache file as well. Here\'s the steps to set up a custom log rotation on a domain...

    1. Edit the httpd.conf file for the domain to point to a directory within the customer\'s home directory. In this example we\'ll use /home/username/logs/. Note that this directory isn\'t web accessible, but the customer will be able to download log files from here.

    In other words, the httpd.conf entry should look like:
    CustomLog /home/username/logs/domain.com combined

    2. Restart httpd

    3. Add an entry that looks like this in the /etc/logrotate.d/apache file:

    /home/username/logs/domain.com {
    rotate 5
    daily
    compress
    }

    The above will rotate each log daily, and keep the log on the system for 5 rotations. You can find out about more options by running man logrotate from the command line. Good luck!

    Brian

    [/quote:45d760ec92] Brian hi.. i just set this up with the same config for one of my domains on my server.. will webalizer still process the log for my domain now with this setup ?

    the domain\'s log file comes to around 1.3GB uncompressed per month

    thanks
     
  10. Brian Farkas

    Brian Farkas Well-Known Member

    Joined:
    Aug 12, 2001
    Messages:
    81
    Likes Received:
    0
    Trophy Points:
    6
    I think it should, but to be honest with you I\'m not 100% sure...
     
  11. eva2000

    eva2000 Well-Known Member

    Joined:
    Aug 14, 2001
    Messages:
    322
    Likes Received:
    9
    Trophy Points:
    18
    Location:
    Brisbane, Australia
    cPanel Access Level:
    Root Administrator
    Twitter:
    apparently doing the above stops cpanel\'s webalizer from generating stats on the log which now resides under the users account :(

    is there any way to get cpanel\'s webalizer to look in that customlog directory as well for that particular domain?
     
  12. pfmartin

    pfmartin Well-Known Member

    Joined:
    Aug 18, 2001
    Messages:
    167
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Earth
    I think this problems is a problem for all servers running cpanel. Is there someone that has a solution? This is the one problem that we have to deal with the keeps us up at night. So far we have the following:

    Option 1: Delete the contents of the domlogs directory whenever things fill up.
    Solves the problem but we loose all log data. Customers don;t like that.

    Option 2: Figure out a way to rotate the logs daily/weekly or whatever. But how do you do this without affecting the stats programs?

    Can anyone please provide some feedback on this?
     
  13. pfmartin

    pfmartin Well-Known Member

    Joined:
    Aug 18, 2001
    Messages:
    167
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Earth
    A comment on my previous post. This problem is more significant with the Code Red type worms out there. Log files grow very very quickly. There must be a way to control the size. We\'ve had one server stop on us a couple of times due to no disk space on /usr. Please!!!
     
  14. moronhead

    moronhead Well-Known Member

    Joined:
    Aug 12, 2001
    Messages:
    706
    Likes Received:
    0
    Trophy Points:
    16
    We have this in /etc/logrotate.d/syslog:

    2> /dev/null is getting repeated twice on each /bin/kill command. Is this normal or is it something freaky?


    /var/log/messages {
    postrotate
    /bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
    endscript
    }

    /var/log/secure {
    postrotate
    /bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
    endscript
    }

    /var/log/maillog {
    postrotate
    /bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
    endscript
    }

    /var/log/spooler {
    postrotate
    /bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
    endscript
    }

    /var/log/boot.log {
    postrotate
    /bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
    endscript
    }

    /var/log/cron {
    postrotate
    /bin/kill -HUP `cat /var/run/syslogd.pid 2>/dev/null` 2>/dev/null || true
    endscript
    }
     
Loading...

Share This Page