Sunday, November 17, 2024
Google search engine
HomeLanguagesWhere does PHP store the error log? (php5, apache, fastcgi, cpanel)

Where does PHP store the error log? (php5, apache, fastcgi, cpanel)

The location of the error log file can be check by using phpinfo() function. Create a simple PHP file containing phpinfo() function and run it. It will display the information about PHP configuration.




<?php phpinfo(); ?>


Run the above program and search for error_log directive using f3 on chrome. This will show the location of the logfile. Following is an example run on WAMP server, but the procedures will be the same as described below for every development stack.

phpinfo()

Open your php.ini file as specified and edit following directives to specify the path of the error log file to some other location.

display_errors = Off

Then you have to give the path to your log file via error_log directive as follows:

logfile
You can find the path to the php.ini file directly using the following command on UNIX/Linux.

php -i | grep php.ini

PHP contains a simple and effective solution to display all log errors into the log file. It is mandatory to turn off displaying error on the server to the end user using a web browser. PHP gives lots of information related to the path, database schema and all other sorts of sensitive information. It strongly advises using error logging in place of error displaying on production web sites. This idea is helpful in displaying the error log to the developer only. PHP offers to log all the errors in a log file instead of displaying the error to the end users via a web browser. To do this first you have to turn off displaying error via a browser in the php.ini file, by setting the display_errors directive to off as mentioned above. Then you have to give the path to your log file via error_log directive as follows:
Ex: error_log = /var/log/php-scripts.log, errors will be logged in php-scripts.log file.

RELATED ARTICLES

Most Popular

Recent Comments