In this complete guide on PHP Error Log we discuss PHP Error Log Location on all operating system and the server. Also we talk about How to create an error log file in PHP with user defined path.
We discuss complete error log path for,
- PHP error log file in WordPress
- Path of PHP error log file in Apache
- PHP error log location in Ubuntu
- Path of PHP error log file in Nginx
Before we start with these, we have to know how we create an Error log file in PHP? and store a user-defined path.
How to Create a PHP Error Log File
//set path where error log file will save
//used to store error data
error_log( "Hello, errors!" );
ini_set()function used to set the php.ini configuration at the time of file execution.
- We ini_set() function for showing errors and notices at the time of PHP file execution.
- After that, we use the same function to set the path of the PHP error log file.
- At last, we use
error_log()to store the error messages.
How to Check PHP Error Log File Location?
If anyone wants to check the current path of the error log file, then they have just created a simple PHP file and execute it with the PHP info function.
<?php phpinfo(); ?>
PHP Error Log File in WordPress
To create an error log file in WordPress, you will need to add the following code in your wp-config.php file just below the WP_DEBUG line.
define( 'WP_DEBUG_LOG', true );
Now save the file and you can see the log file in following path,
Path of PHP Error Log File in Apache
PHP Error Log Location in Ubuntu
This can be configured in
Path of PHP Error Log File in Nginx
To check the data on the file, run the following command on terminal,
sudo tail /var/log/nginx/error.log -n 200
If you want to know more about error log in PHP you can check the official site https://www.php.net/
- Best Way to Download Video From YouTube
- Explain Different Parts of The URL With Example
- What Does int(11) mean in MySQL With Example
- Import and Export CSV file in PHP