Welcome to Centmin Mod Community
Register Now

[Solved] NGINX vhost logs

Discussion in 'Bug Reports' started by Tracy Perry, Mar 14, 2016.

  1. Tracy Perry

    Tracy Perry Active Member

    276
    115
    43
    Aug 24, 2014
    Texas
    Ratings:
    +205
    Local Time:
    1:36 AM
    1.21.6
    MariaDB 10.3.36
    Is anyone else having issues with the latest BETA not rotating the logs as expected. My vhosts have access/error logs with entries dating back to 02/2016 (when I set the new server up). Logs in the /var/log location are apparently being rotated correctly.

     
  2. Tracy Perry

    Tracy Perry Active Member

    276
    115
    43
    Aug 24, 2014
    Texas
    Ratings:
    +205
    Local Time:
    1:36 AM
    1.21.6
    MariaDB 10.3.36
    OK.. some testing shows that the normal nginx log routine has this in it
    Code:
            daily
            dateext
            missingok
            rotate 5
            size=500M
            compress
            delaycompress
            notifempty
            postrotate
    and will NOT run on my system and archive the vhost nginx logs.

    I created a new nginx_domains in the /etc/logrotate.d directory that contains
    Code:
            daily
            dateext
            missingok
            rotate 5
            compress
            delaycompress
            postrotate
    and the process runs fine. For those that don't want to do the comparison, I removed the size=500M and the notifempty parameters.
     
    Last edited: Mar 14, 2016
  3. eva2000

    eva2000 Administrator Staff Member

    53,191
    12,113
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,649
    Local Time:
    4:36 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    so you logs are smaller than 500MB ?

    Which CentOS version 6.x or 7.x ? contents of
    • /etc/logrotate.d/nginx
    • /etc/logrotate.d/php-fpm
    size of the logs ? from command where yourdomain.com is changed to your vhost domain name
    Code (Text):
    ls -lAhrt /home/nginx/domains/yourdomain.com/log/
    total 0
    -rw-r--r-- 1 root root 0 Mar 11 03:26 error.log
    -rw-r--r-- 1 root root 0 Mar 11 03:26 access.log
     
  4. Tracy Perry

    Tracy Perry Active Member

    276
    115
    43
    Aug 24, 2014
    Texas
    Ratings:
    +205
    Local Time:
    1:36 AM
    1.21.6
    MariaDB 10.3.36
    Derp... makes sense... but no, they were not. I've still removed the 500M aspect as I want them to be done on a regular basis and not dependent upon file sizes (for consistent archival time periods).
     
  5. eva2000

    eva2000 Administrator Staff Member

    53,191
    12,113
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,649
    Local Time:
    4:36 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    I see, well the reason why I set it up this way was to ensure no log file ever got past 500MB in a 24hr period due to Centmin Mod originally being for the LEB - lowendbox types where folks had little disk and ram available. But I think I used the wrong option. Sounds like for /etc/logrotate.d/nginx, i should change from size to maxsize. Maxsize option tells logrotate to rotate on defined time = daily, but rotate a log if it gets to 500MB size even before the end of the 24hr period (daily). Size instead gives rotate priority to the size and not the defined time.

    so change from
    Code (Text):
    size=500M

    Code (Text):
    maxsize 500M
     
    Last edited: Mar 15, 2016
  6. Tracy Perry

    Tracy Perry Active Member

    276
    115
    43
    Aug 24, 2014
    Texas
    Ratings:
    +205
    Local Time:
    1:36 AM
    1.21.6
    MariaDB 10.3.36
    Probably be a worthwhile change... I'm not really worried about the file size that accumulates in 1 day. For me, it's the time period that is important. I don't really care if the log is 5 meg or 5 gig. ;)
     
  7. eva2000

    eva2000 Administrator Staff Member

    53,191
    12,113
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,649
    Local Time:
    4:36 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    might add a check to see how much memory and disk space a server has to determine if i set the maxsize :)
     
  8. eva2000

    eva2000 Administrator Staff Member

    53,191
    12,113
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,649
    Local Time:
    4:36 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+