Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find out the error_log's path

Tags:

php

apache

I have this domain.com pointed to /home/username/public_html/domain.com.

I added these lines to the .htaccess file:

ErrorDocument 500 /oohps.php
ErrorDocument 404 /where.php

So I can show some styled template.

The problem is that when trying to access a nonexisting page, I get an additional internal server error, so these files are not opened.

I wanted to check for the logs, but I cannot find the error log in that path (/home/username/public_html/domain.com).

I found one in /var/log/httpd, but I don't think it’s the right folder, because there are many errors not involved with this page and I didn't see any involved.

Is there a PHP function that would output the errors log file path?

like image 689
Toni Michel Caubet Avatar asked Jan 21 '12 18:01

Toni Michel Caubet


2 Answers

An internal server error has often something to do with Apache and /var/log/httpd/ is the error log file of Apache, so I think you are in the right file.


The error path is set in php.ini. To get the path use ini_get():

<?php
  $errorPath = ini_get('error_log');
?>
like image 146
Wouter J Avatar answered Oct 12 '22 08:10

Wouter J


To only get the path where PHP stores its logs, use:

pathinfo(ini_get('error_log'),PATHINFO_DIRNAME);

Which should return something like this (on localhost):

/Applications/MAMP/logs
like image 42
bart Avatar answered Oct 12 '22 09:10

bart