Get the most out of your Centmin Mod LEMP stack
Become a Member

PHP-FPM PHP-FPM logs stopped

Discussion in 'Nginx, PHP-FPM & MariaDB MySQL' started by quicksalad, Nov 28, 2022.

  1. quicksalad

    quicksalad Member

    193
    13
    18
    May 31, 2015
    Ratings:
    +19
    Local Time:
    3:11 AM
    I noticed PHP-FPM is no longer logging to the recent date. NGINX is still logging, website is running okay.
    Any advice why this happen?
    Code:
    ● php-fpm.service - PHP FastCGI Process Manager
       Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; enabled; vendor pres                                                                                                                                                             et: disabled)
      Drop-In: /etc/systemd/system/php-fpm.service.d
               └─limit.conf
       Active: active (running) since Sun 2022-11-27 16:04:34 UTC; 6h ago
     Main PID: 32450 (php-fpm)
       CGroup: /system.slice/php-fpm.service
               └─32450 php-fpm: master process (/usr/local/etc/php-fpm.conf)


     
  2. eva2000

    eva2000 Administrator Staff Member

    49,762
    11,447
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +17,789
    Local Time:
    7:41 AM
    Nginx 1.21.x
    MariaDB 10.x
    Where are you looking for the logs? PHP-FPM log would be in /var/log/php-fpm

    What's output for command
    Code (Text):
    ls -lAhrt /var/log/php-fpm
     
  3. quicksalad

    quicksalad Member

    193
    13
    18
    May 31, 2015
    Ratings:
    +19
    Local Time:
    3:11 AM
    Please see out code below
    Code:
     ls -lAhrt /var/log/php-fpm
    total 80K
    -rw-rw-rw-. 1 root  root    0 Apr  7  2022 www-slow.log
    -rw-rw-rw-. 1 nginx nginx   0 Apr  8  2022 www-slowmyadmin.log
    -rw-rw-rw-. 1 root  root  150 May 25  2022 www-error.log-20220526.gz
    -rw-rw-rw-. 1 root  root  140 May 26  2022 www-error.log-20220527.gz
    -rw-rw-rw-. 1 root  root  136 May 30 07:38 www-error.log-20220531.gz
    -rw-rw-rw-. 1 root  root  148 Jun  1 14:10 www-error.log-20220602.gz
    -rw-rw-rw-. 1 root  root  119 Jul  4 12:25 www-error.log-20220705.gz
    -rw-rw-rw-. 1 root  root  119 Jul 14 15:57 www-error.log-20220715.gz
    -rw-rw-rw-. 1 root  root  119 Aug 28 15:08 www-error.log-20220829.gz
    -rw-rw-rw-. 1 root  root  243 Sep  4 13:13 www-php.error.log-20220905.gz
    -rw-rw-rw-. 1 root  root   80 Sep  7 16:09 www-php.error.log-20220908.gz
    -rw-rw-rw-. 1 root  root  147 Sep 12 06:43 www-error.log-20220913.gz
    -rw-rw-rw-. 1 root  root  135 Sep 19 13:03 www-error.log-20220920.gz
    -rw-rw-rw-. 1 root  root  398 Sep 21 15:18 www-php.error.log-20220922.gz
    -rw-rw-rw-. 1 root  root  211 Sep 22 11:46 www-php.error.log-20220923.gz
    -rw-rw-rw-. 1 root  root  132 Sep 30 08:28 www-php.error.log-20221001.gz
    -rw-rw-rw-. 1 root  root  183 Oct 11 07:01 www-php.error.log-20221012.gz
    -rw-rw-rw-. 1 root  root  210 Oct 13 11:49 www-error.log-20221014
    -rw-rw-rw-. 1 root  root    0 Oct 14 03:23 www-error.log
    -rw-rw-rw-. 1 root  root  182 Oct 29 03:48 www-php.error.log-20221030.gz
    -rw-rw-rw-. 1 root  root  202 Oct 31 01:46 www-php.error.log-20221031.gz
    -rw-rw-rw-. 1 root  root  186 Nov  4 11:53 www-php.error.log-20221105.gz
    -rw-rw-rw-. 1 root  root  473 Nov 10 11:22 www-php.error.log-20221111
    -rw-rw-rw-. 1 root  root    0 Nov 11 03:41 www-php.error.log
    
    I was looking on above texts, it stopped Nov 11
    Please help also move the thread to the right category. Thank you.
     
  4. eva2000

    eva2000 Administrator Staff Member

    49,762
    11,447
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +17,789
    Local Time:
    7:41 AM
    Nginx 1.21.x
    MariaDB 10.x
    what's output for logrotate config file at /etc/logrotate.d/php-fpm
    Code (Text):
    cat /etc/logrotate.d/php-fpm
    

    and output for logrotate debug run
    Code (Text):
    logrotate -d /etc/logrotate.d/php-fpm
    

    and verbose run
    Code (Text):
    logrotate -v /etc/logrotate.d/php-fpm
    

    Though could simply be you don't have any new PHP errors to log. You can try running a dummy PHP script with code that would error out and see if it gets logged.
     
  5. quicksalad

    quicksalad Member

    193
    13
    18
    May 31, 2015
    Ratings:
    +19
    Local Time:
    3:11 AM
    @eva2000 please see output below fyr
    Code:
     cat /etc/logrotate.d/php-fpm
    /var/log/php-fpm/*.log {
            daily
            dateext
            missingok
            rotate 10
            compress
            delaycompress
            notifempty
            postrotate
            /bin/kill -SIGUSR1 $(cat /var/run/php-fpm/php-fpm.pid 2>/dev/null) 2>/dev/null || true
            endscript
    }
    Code:
    logrotate -d /etc/logrotate.d/php-fpm
    reading config file /etc/logrotate.d/php-fpm
    Allocating hash table for state file, size 15360 B
    
    Handling 1 logs
    
    rotating pattern: /var/log/php-fpm/*.log  after 1 days (10 rotations)
    empty log files are not rotated, old logs are removed
    considering log /var/log/php-fpm/www-error.log
      log does not need rotating (log is empty)considering log /var/log/php-fpm/www-php.error.log
      log does not need rotating (log is empty)considering log /var/log/php-fpm/www-slow.log
      log does not need rotating (log is empty)considering log /var/log/php-fpm/www-slowmyadmin.log
    Code:
     logrotate -v /etc/logrotate.d/php-fpm
    reading config file /etc/logrotate.d/php-fpm
    Allocating hash table for state file, size 15360 B
    
    Handling 1 logs
    
    rotating pattern: /var/log/php-fpm/*.log  after 1 days (10 rotations)
    empty log files are not rotated, old logs are removed
    considering log /var/log/php-fpm/www-error.log
      log does not need rotating (log is empty)considering log /var/log/php-fpm/www-php.error.log
      log does not need rotating (log is empty)considering log /var/log/php-fpm/www-slow.log
      log does not need rotating (log is empty)considering log /var/log/php-fpm/www-slowmyadmin.log
      log does not need rotating (log is empty)set default create context
    I did try
    Code:
    <?php
     $file = fopen("notavailable.txt", "w");
    ?>
    Still no error logs
     
  6. eva2000

    eva2000 Administrator Staff Member

    49,762
    11,447
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +17,789
    Local Time:
    7:41 AM
    Nginx 1.21.x
    MariaDB 10.x
    What's output for command below
    Code (Text):
    egrep 'error_log|log_level|slowlog' /usr/local/etc/php-fpm.conf
    

    and
    Code (Text):
    php -i | grep log_errors
     
  7. quicksalad

    quicksalad Member

    193
    13
    18
    May 31, 2015
    Ratings:
    +19
    Local Time:
    3:11 AM
    Code:
     egrep 'error_log|log_level|slowlog' /us                                                                                                                                                             r/local/etc/php-fpm.conf
    log_level = warning
    error_log = /var/log/php-fpm/www-error.log
    ;request_slowlog_timeout = 0
    slowlog = /var/log/php-fpm/www-slow.log
    php_admin_value[error_log] = /var/log/php-fpm/www-php.error.log
    You have new mail in /var/spool/mail/root
    Code:
    php -i | grep log_errors
    log_errors => On => On
    log_errors_max_len => 1024 => 1024
    I checked before posting this, the www-php.error.log is now on recent date (maybe triggered by the php script above?), while www-error.log, www-slow.log and slowmyadminlog is not updating to the recent date.
     
    Last edited: Nov 29, 2022
  8. eva2000

    eva2000 Administrator Staff Member

    49,762
    11,447
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +17,789
    Local Time:
    7:41 AM
    Nginx 1.21.x
    MariaDB 10.x
    That and the command output you posted suggests PHP error logging is working fine just you don't have any PHP errors to log until now :)
     
  9. quicksalad

    quicksalad Member

    193
    13
    18
    May 31, 2015
    Ratings:
    +19
    Local Time:
    3:11 AM
    @eva2000 Thanks as always!