laravelwordpresslaravel-valetlaravel-herd

Laravel Herd + Wordpress not writing to debug.log


I've just changed to Laravel Herd earlier this week and needed to run Wordpress debugging on a theme I'm developing. This is where I noticed that Wordpress doesn't seem to be creating a/writing to debug.log-file when it's run through Herd.

I have the standard debug-definitions in my wp-config:

define( 'WP_DEBUG', true );
// Enable Debug logging to the /wp-content/debug.log file
define( 'WP_DEBUG_LOG', true );
// Disable display of errors and warnings
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );

I also have a write_log()-function, which should write to the same file, but nothing happens. This is the function:

if (!function_exists('write_log')) {
    function write_log($log) {
        if (true === WP_DEBUG) {
            if (is_array($log) || is_object($log)) {
                error_log(print_r($log, true));
            } else {
                error_log($log);
            }
        }
    }
}

This can be replicated with a clean Wordpress install by adding this to the wp-config.php

// Enable WP_DEBUG mode
define( 'WP_DEBUG', true );
// Enable Debug logging to the /wp-content/debug.log file
define( 'WP_DEBUG_LOG', true );
// Disable display of errors and warnings
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );

// Disable file editor
define('DISALLOW_FILE_EDIT', true);

error_log(print_r('hello', true));

The above snippet SHOULD write hello to the debug-file, but nothing happens.

Any tricks to activate Wordpress debugging on Laravel Herd?


Solution

  • "Laravel Herd" writes logs to /Users/{user_name}/Library/Application Support/Herd/Log/php-fpm.log file.

    You need to go to /Users/{user_name}/Library/Application Support/Herd/Config/fpm directory. There you will find files for different php versions. Example: [php_version]-fpm.config

    Open each file and comment out php_admin_value[error_log] = /Users/{user_name}/Library/Application line by adding a semicolon ; in front of the line.

    Example:

    ;php_admin_value[error_log] = /Users/{user_name}/Library/Application
    

    After that go to herd and stop all services and again start all services.

    You should see your logs in wp-contents/debug.log file.

    Source: https://github.com/beyondcode/herd-community/issues/134