error log pathCheck error log path

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,

  1. PHP error log file in WordPress
  2. Path of PHP error log file in Apache
  3. PHP error log location in Ubuntu
  4. Path of PHP error log file in Nginx
Complete Guide: PHP Error Log
Complete Guide: PHP Error Log

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

Code Explanations:

  • 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.

Output:

error log path
Check error log path

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,

/wp-content/debug.log

Path of PHP Error Log File in Apache

/usr/local/apache2/logs/error_log

PHP Error Log Location in Ubuntu

By default, /var/log/apache2/error.log.
This can be configured in /etc/php5/apache2/php.ini.

Path of PHP Error Log File in Nginx

/var/log/nginx/error.log

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/

[helpie_faq group_id=’6279’/]

Also Check:

Happy Coding..!

Was this article helpful?
YesNo

By Bikash

My name is Bikash Kr. Panda. I own and operate PHPCODER.TECH. I am a web Programmer by profession and working on more than 50 projects to date. Currently I am working on the web-based project and all the CMS and frameworks which are based on PHP.

6 thoughts on “Complete Guide PHP Error Log”

Leave a Reply

Your email address will not be published. Required fields are marked *