Page 1 of 1

[Solved] Error log huge

Posted: Sat May 09, 2015 6:12 am
by vandread911
i don't know why my error log gets so big i have to remove it each week or else the site does not work,
Image - in the pic its 461 GB big

is there a way of disabling error log or limiting it to max 100mb

Re: Error log huge

Posted: Mon May 11, 2015 8:14 pm
by skurudo
Edit your apache/nginx in /etc/logrotate.d/ and add size option.

According to manpage:
minsize size
Log files are rotated when they grow bigger than size bytes,
but not before the additionally specified time interval (daily,
weekly, monthly, or yearly). The related size option is simi-
lar except that it is mutually exclusive with the time interval
options, and it causes log files to be rotated without regard
for the last rotation time. When minsize is used, both the
size and timestamp of a log file are considered.

size size
Log files are rotated only if they grow bigger then size bytes.
If size is followed by k, the size is assumed to be in kilo-
bytes. If the M is used, the size is in megabytes, and if G is
used, the size is in gigabytes. So size 100, size 100k, size
100M and size 100G are all valid.
maxsize size
Log files are rotated when they grow bigger than size bytes even before
the additionally specified time interval (daily, weekly, monthly,
or yearly). The related size option is similar except that it
is mutually exclusive with the time interval options, and it causes
log files to be rotated without regard for the last rotation time.
When maxsize is used, both the size and timestamp of a log file are
considered.
Example (do not copy this!)

Code: Select all

/var/log/httpd/error.log {
           rotate 5
           mail [email protected]
           size 100k
           sharedscripts
           postrotate
               /usr/bin/killall -HUP httpd
           endscript
       }

Re: Error log huge

Posted: Wed May 13, 2015 3:13 pm
by vandread911
skurudo wrote:Edit your apache/nginx in /etc/logrotate.d/ and add size option.

According to manpage:
minsize size
Log files are rotated when they grow bigger than size bytes,
but not before the additionally specified time interval (daily,
weekly, monthly, or yearly). The related size option is simi-
lar except that it is mutually exclusive with the time interval
options, and it causes log files to be rotated without regard
for the last rotation time. When minsize is used, both the
size and timestamp of a log file are considered.

size size
Log files are rotated only if they grow bigger then size bytes.
If size is followed by k, the size is assumed to be in kilo-
bytes. If the M is used, the size is in megabytes, and if G is
used, the size is in gigabytes. So size 100, size 100k, size
100M and size 100G are all valid.
maxsize size
Log files are rotated when they grow bigger than size bytes even before
the additionally specified time interval (daily, weekly, monthly,
or yearly). The related size option is similar except that it
is mutually exclusive with the time interval options, and it causes
log files to be rotated without regard for the last rotation time.
When maxsize is used, both the size and timestamp of a log file are
considered.
Example (do not copy this!)

Code: Select all

/var/log/httpd/error.log {
           rotate 5
           mail [email protected]
           size 100k
           sharedscripts
           postrotate
               /usr/bin/killall -HUP httpd
           endscript
       }

Within:

Code: Select all

/etc/logrotate.d/httpd
mine is this:
/var/log/httpd/*log /var/log/httpd/domains/*log {
missingok
notifempty
compress
sharedscripts
postrotate
/sbin/service httpd reload > /dev/null 2>/dev/null || true
[ ! -f /var/run/nginx.pid ] || kill -USR1 `cat /var/run/nginx.pid`
endscript
}
would i have to edit this:

Code: Select all

    missingok
    notifempty
    compress
    sharedscripts
    postrotate
        /sbin/service httpd reload > /dev/null 2>/dev/null || true
        [ ! -f /var/run/nginx.pid ] || kill -USR1 `cat /var/run/nginx.pid`
    endscript
to:

Code: Select all

           rotate 5
           mail [email protected]
           size 50M
           sharedscripts
           postrotate
               /usr/bin/killall -HUP httpd
           endscript
if i would like it to rotate when it hits 50Mb

Re: Error log huge

Posted: Wed May 13, 2015 10:48 pm
by skurudo
vandread911 wrote:if i would like it to rotate when it hits 50Mb
Look nice.
And you can edit apache2.conf and log not all error, but only critical.