wp-rocket icon indicating copy to clipboard operation
wp-rocket copied to clipboard

Improve the Logger functionality to reduce the size of the log file

Open girlie opened this issue 9 months ago • 3 comments

Describe the bug Certain Logger functions have the potential to generate a large amount of output into the wp-rocket-debug.log.html file, which becomes difficult (if not impossible) to open, read, search, etc., and can even take some sites down. (This is why I filed this as a bug rather than an enhancement.)

For example, this code for logging the replacement of CSS images with the lazyloaded version writes the entire HTML output from the page being processed into the log:

https://github.com/wp-media/wp-rocket/blob/3c046b5332ec1175a498d32765862d87be7a0112/inc/Engine/Media/Lazyload/CSS/Subscriber.php#L167

So it's much like having every cache file all merged together in a single file, and then some. (I have one case where each cache file is 1.5MB or larger, and with approximately 800 URLs to be processed, that would mean a minimum size of 1.2GB for the log file by the time it's all done.)

Other possibilities for further refinement/reconsideration:

  • DEBUG: Found XX <link> tags
  • NOTICE: Skipped URL
  • NOTICE: Extracted Content

It seems most of us probably use this file to diagnose wpr not cached issues; so as listed by Camila, we're mostly looking at the logger entries for:

  • donotcachepage set
  • buffer content under 255
  • excluded or mandatory cookie
  • config file not found

Most of the above was extracted from this Slack thread: https://group-onecom.slack.com/archives/C08EFUD9XLJ/p1743007363049459

girlie avatar Apr 07 '25 15:04 girlie

This is important, as the current status of the WP_ROCKET_DEBUG makes it risky because the log file will grow very fast, breaking the WP Rocket UI and potentially filling the server space

related issue: https://github.com/wp-media/wp-rocket/issues/6618

alfonso100 avatar Apr 09 '25 14:04 alfonso100

Related: https://group-onecom.slack.com/archives/C08EFCZ68NP/p1748363910537829?thread_ts=1748363066.217769&cid=C08EFCZ68NP https://secure.helpscout.net/conversation/2950035398/563059

joejoe04 avatar May 29 '25 14:05 joejoe04

Rocket Care customer: https://secure.helpscout.net/conversation/2951101774/563312

Issue: Due to the site traffic (Preload was off), the log file kept growing to the point where the server became irresponsive. This highly impacted the Rocket Care installation process and the customer experience since we crashed their server 😥

camilamadronero avatar May 29 '25 14:05 camilamadronero