Where Does PHP Store Error Log

Checking the location of the error log in PHP is one of the common actions that any developer might take during work. However, it can seem tricky at times. This snippet will represent to you where the error log is stored in PHP.All you need to do is following the steps below:

Watch a course Learn object oriented PHP

Using the phpinfo() Function

You can easily check the location of the error log by applying the phpinfo() function:

<?php phpinfo(); ?>

Watch a course Learn object oriented PHP

Here are the steps you need to take:

Run the program searching for the error_log directive.

That will display the logfile location.

Open php.ini

The second step is opening thephp.ini file and editing the directives to indicate the path of the error log file.

display_errors = Off

Give path to the log file

The third step is giving a path to the log file through the error_log directive. The path to the php.ini file can be found directly by applying the command below on UNIX/Linux:

php -i | grep php.ini

PHP encounters a handy and effective solution to demonstrate all the log errors within one log file.

PHP gives a full range of information about the database schema, path, and so on. It strongly recommends to apply error logging in the place of error demonstration on production web sites.

PHP recommends logging all the errors in a log file instead of showing an error to the end users through a web browser.

To do that, it is first, necessary to turn off displaying errors directive as shown above. Then it is needed to give the path to the log file through error_log directive like this:

Ex: error_log = /var/log/php-scripts.log