Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Janis Elsts

    (@whiteshadow)

    It’s easier to demonstrate with an example. With this option disabled, error messages might look like this:

    PHP Warning: strip_tags() expects parameter 1 to be string, array given in /home/username123456/public_html/wpdirectory/wp-includes/formatting.php on line 4230

    With the “strip” option enabled, that message will look like this instead:

    PHP Warning: strip_tags() expects parameter 1 to be string, array given in /wp-includes/formatting.php on line 4230

    This option has no effect on which messages are displayed. It only changes how they are displayed, i.e. formatting.

    Thread Starter John

    (@dsl225)

    Great, that’s cool!

    What about my second question?
    – will the plugin also display error-log messages found under /wp-admin/ and other WP folders such as /wp-content/?

    Plugin Author Janis Elsts

    (@whiteshadow)

    It’ll display all error messages it finds in the log. However, it will only look at one log file. If you have multiple error log files in different directories, this plugin will only display messages from the file that’s configured as “the” error log in php.ini or wp-config.php.

    Thread Starter John

    (@dsl225)

    Many thanks for this but all WP sites I work with get error log files also in /wp-admin/ folder and sometimes under /wp-content/plugins/ and there is nothing about that in wp-config.php file.

    In other words, log files may be found at several locations in a WP structure.
    Is there a way to send them all to the main log file your plugin reads?

    Plugin Author Janis Elsts

    (@whiteshadow)

    You can configure PHP to log all errors to one specific file. Use the “error_log” directive in php.ini:
    https://php.net/manual/en/errorfunc.configuration.php#ini.error-log

    Alternatively, you could do something like this, but it won’t catch errors that are generated outside WordPress:
    https://digwp.com/2009/07/monitor-php-errors-wordpress/

    Note that the log file needs to be readable by WordPress, otherwise the plugin won’t be able to display its contents.

    Thread Starter John

    (@dsl225)

    Thanks for this, I’ve already done this and waiting to see what happens with errors logged under wp-admin (don’t have any for the time being).

    I really wonder what exactly means, in terms of file permissions “readable by WordPress”?

    Plugin Author Janis Elsts

    (@whiteshadow)

    I really wonder what exactly means, in terms of file permissions “readable by WordPress”?

    That really depends on your server configuration. In general, all PHP scripts run as a particular user. It could be the same user ID as the one used by the web server process, or it could be nobody, or it could be your own account. Whatever it is, that user needs read access to the file.

    Thread Starter John

    (@dsl225)

    OK thanks.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Strip WordPress root directory from log messages’ is closed to new replies.