Getting errors to show

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
New php-forum User
New php-forum User
Posts: 8
Joined: Sat Feb 25, 2017 10:30 am

Mon May 24, 2021 9:08 am

I'm developing a PHP website. It is running on a shared Linux/Apache server. I am logging errors in two ways:
  1. By calling error_log($message, $message_type, $destination, $extra_headers);
  2. By calling my own logmsg() function that writes to the log file using fwrite($logf, $logmsg);
Sometimes when I request a page that fails to load, it fails to write anything to the log file, even though I am 99% certain that it will have executed a number of error_log() and logmsg() calls. I suspect that the output is getting stuck in some buffer somewhere. How do I get to see these log messages? Is there a way to flush the output to the log file? Without being able to see these messages it's very difficult to work out why the page is failing to load.

Thank you - Rowan
User avatar
php-forum GURU
php-forum GURU
Posts: 1222
Joined: Mon Feb 22, 2016 5:52 pm

Mon May 24, 2021 9:59 am

Start by setting PHP to display errors [in you php.ini file]; if you have a fatal PHP error, it will exit without executing your code - display errors will say something which will help narrow down where the error is.
Post Reply