Store PHP error log file in script directory without adding php code to existing scripts

I was busy setting up my own VPS after using in cpanel,

but I can’t figure out how to create the PHP error_log file in the same directory as the script that throws the errors.

I would like this to happen without me to add a line of code to every .php file. In Cpanel, it somehow works out of the box.

Example:

error in: /var/www/webapp1/index.php log file location: /var/www/webapp1/error_log

error: /var/www/info/system/test.php log file location: /var/www/info/system/error_log

Basically I want php to store the error_log file in each directory for scripts in this directory.

Additional Information:

  • Single VPS Account
  • Debian GNU / Linux 6.0 'Squeeze'
  • Apache 2.2.16
+7
source share
4 answers

Set the error_log value to the name of the error log that you want to display in the directory, but do not put any slashes. The file will be saved in the directory from which the script is run, therefore in the same directory.

 error_log = "php_error.log" 
+4
source

There is an error_log directive in php.ini for this, like:

 error_log string 

Where the string represents the name of the file in which script errors should be logged. The file must be writable by the web server user. If the special syslog value is used, errors are sent to the system log. On Unix, this means syslog (3), and on Windows NT, it means an event log. The system logger is not supported on Windows 95. See Also: syslog () . If this directive is not set, errors are sent to the SAPI error log. For example, this is the error log in Apache or stderr in the CLI.

+2
source

Basically I want php to store the error_log file in each directory for scripts in this directory

Assuming you are using Apache, you can use the Apache error_log directive in VirtualHost to achieve this behavior. If memory suits me, PHP by itself does not determine where it stores its errors.

+1
source

Edit your php.ini and do not follow these steps:

 error_log = php_errors.log 

Save the changes, restart apache, be happy.

If you are using linux , open a terminal and enter this to restart:

 sudo services apache2 restart 

If you have access to WHM , you can search for services and restart HTTPD or Apache

If you use Easyphp or Vertrigo , you can do this through the program yourself.

0
source

All Articles