Same log message keeps on printing to debug.log file thousand of times [PHP,WordPress]

So i was debugging my PHP code while working with WordPress site by writing to debug.log with error_log($message) or trigger_error($message).

My message in these log statements keeps on printing thousand of times in debug.log file from a same single statment declared in functions.php (for example purpose here i am logging from themes’s functions.php which results in same issue of multiple printing though i was debugging from some snippet plugin)

Accordingly to check if this issue is caused by my code their in functions.php or snippet plugin being called multiple times i tried logging wih different mechanism [chrome console log & chrome browser alert], result was php debug log message was printed multiple times though chrome console log & chrome browser alert was only one time. So i believe my code is not running multiple times but debug log messages as printed by error_log or trigger_error is printed multiple times & keeps on printing thousand of times.

So i thought it could be due to my local development enviroment than i tried same thing in a fresh wordpress installation in a real environment, same thing happened. So found no solution/explaination to it yet.

MY THEME’S functions.php WITH ALL TESTED CODE:

.
.
.
//continuously keeps on printing in debug.log (many times)
$debug_log = “DEBUG-debug log”;
trigger_error($debug_log);
//OR
error_log($debug_log);

//prints only one time in chrome console
$debug_console = “DEBUG-console”;
echo “<script>console.log(‘$debug_console’);</script>”;

//alerts only one time in chrome
$debug_alert = “DEBUG-alert”;
echo “<script type=’text/javascript’>alert(‘$debug_alert’);</script>”;

MY debug.log FILE IS LIKE THIS:

[14-Jan-2019 01:05:50 UTC] PHP Notice: DEBUG-debug log in /app/public/wp-content/themes/Avada-Child-Theme/functions.php on line 15
[14-Jan-2019 01:05:51 UTC] PHP Notice: DEBUG-debug log in /app/public/wp-content/themes/Avada-Child-Theme/functions.php on line 15
[14-Jan-2019 01:05:51 UTC] PHP Notice: DEBUG-debug log in /app/public/wp-content/themes/Avada-Child-Theme/functions.php on line 15
[14-Jan-2019 01:05:54 UTC] PHP Notice: DEBUG-debug log in /app/public/wp-content/themes/Avada-Child-Theme/functions.php on line 15
[14-Jan-2019 01:05:55 UTC] PHP Notice: DEBUG-debug log in /app/public/wp-content/themes/Avada-Child-Theme/functions.php on line 15
[14-Jan-2019 01:05:59 UTC] PHP Notice: DEBUG-debug log in /app/public/wp-content/themes/Avada-Child-Theme/functions.php on line 15
[14-Jan-2019 01:06:04 UTC] PHP Notice: DEBUG-debug log in /app/public/wp-content/themes/Avada-Child-Theme/functions.php on line 15
[14-Jan-2019 01:06:25 UTC] PHP Notice: DEBUG-debug log in /app/public/wp-content/themes/Avada-Child-Theme/functions.php on line 15
[14-Jan-2019 01:06:26 UTC] PHP Notice: DEBUG-debug log in /app/public/wp-content/themes/Avada-Child-Theme/functions.php on line 15
[14-Jan-2019 01:06:26 UTC] PHP Notice: DEBUG-debug log in /app/public/wp-content/themes/Avada-Child-Theme/functions.php on line 15
[14-Jan-2019 01:06:27 UTC] PHP Notice: DEBUG-debug log in /app/public/wp-content/themes/Avada-Child-Theme/functions.php on line 15
[14-Jan-2019 01:06:29 UTC] PHP Notice: DEBUG-debug log in /app/public/wp-content/themes/Avada-Child-Theme/functions.php on line 15
[14-Jan-2019 01:06:31 UTC] PHP Notice: DEBUG-debug log in /app/public/wp-content/themes/Avada-Child-Theme/functions.php on line 15
[14-Jan-2019 01:06:31 UTC] PHP Notice: DEBUG-debug log in /app/public/wp-content/themes/Avada-Child-Theme/functions.php on line 15
[14-Jan-2019 01:06:31 UTC] PHP Notice: DEBUG-debug log in /app/public/wp-content/themes/Avada-Child-Theme/functions.php on line 15
[14-Jan-2019 01:06:32 UTC] PHP Notice: DEBUG-debug log in /app/public/wp-content/themes/Avada-Child-Theme/functions.php on line 15
[14-Jan-2019 01:06:47 UTC] PHP Notice: DEBUG-debug log in /app/public/wp-content/themes/Avada-Child-Theme/functions.php on line 15
[14-Jan-2019 01:07:02 UTC] PHP Notice: DEBUG-debug log in /app/public/wp-content/themes/Avada-Child-Theme/functions.php on line 15
[14-Jan-2019 01:07:17 UTC] PHP Notice: DEBUG-debug log in /app/public/wp-content/themes/Avada-Child-Theme/functions.php on line 15
[14-Jan-2019 01:07:29 UTC] PHP Notice: DEBUG-debug log in /app/public/wp-content/themes/Avada-Child-Theme/functions.php on line 15
[14-Jan-2019 01:07:31 UTC] PHP Notice: DEBUG-debug log in /app/public/wp-content/themes/Avada-Child-Theme/functions.php on line 15
[14-Jan-2019 01:07:32 UTC] PHP Notice: DEBUG-debug log in /app/public/wp-content/themes/Avada-Child-Theme/functions.php on line 15
[14-Jan-2019 01:07:47 UTC] PHP Notice: DEBUG-debug log in /app/public/wp-content/themes/Avada-Child-Theme/functions.php on line 15
[14-Jan-2019 01:08:02 UTC] PHP Notice: DEBUG-debug log in /app/public/wp-content/themes/Avada-Child-Theme/functions.php on line 15

Read more here:: Same log message keeps on printing to debug.log file thousand of times [PHP,Wordpress]

Leave a Reply

Your email address will not be published. Required fields are marked *