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.
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.
- Difference Between Apache Kafka and Apache Flume
- Difference Between Apache Hadoop and Apache Storm
- Difference Between Apache Hive and Apache Impala
- Difference between Apache Tomcat server and Apache web server
- How to run two PHP versions for two projects on same apache server ?
- PHP Math Functions (is_nan, pow, sqrt, exp, log, log10, log1p, max, min, getrandmax, rand, mt_rand)
- How to log errors and warnings into a file in php?
- PHP | log(), log10() Functions
- Introduction to Redux (Action, Reducers and Store)
- How to store deployment configuration files in Node.js ?
- How to store password securely in your local/custom database in Node.js ?
- How to Sign In with raw password when password store in the database are hashed form in Node.js ?
- How to Build Progressive Web Application and Submit it to the Play Store?
- Why Laravel Aimeos Is a Good Choice for Building an Online Store ?
- Introduction to Apache Maven | A build automation tool for Java projects
- Apache POI | Introduction
- Reading and Writing data to excel file using Apache POI
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.