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.

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:

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.
Recommended Posts:
- Apache POI | Introduction
- Apache Kafka | Introduction
- How to install Apache server in Ubuntu ?
- AWS EC2 Instance Setup with Apache Server
- How to make sure that Apache service keeps running in Ubuntu
- Introduction to PySpark | Distributed Computing with Apache Spark
- Reading and Writing data to excel file using Apache POI
- Introduction to Apache Maven | A build automation tool for Java projects
- How to store all dates in an array present in between given two dates in JavaScript ?
- Error handling in PHP
- How to test a URL for 404 error in PHP?
- jQuery | error() Method
- JavaScript | Error name Property
- JavaScript | Error message Property
- Node.js | console.error() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



