Reputation: 8980
I created a PHP script to read the error log file in a customized visual format, but right now, I have the path to the error log file hard-coded in, which works fine for me, but I would like to find out if there's a way to pull the path to the error_log automatically so it can work on any server without further configuration.
Upvotes: 1
Views: 110
Reputation: 24431
You can use ini_get to obtain the error_log path in PHP.
$error_log = ini_get('error_log');
Otherwise, you'd be relegated to using something like:
<?php
ob_start();
phpinfo(INFO_CONFIGURATION);
$phpinfo = ob_get_contents();
ob_end_clean();
preg_match('#error_log</td><td\b[^>]*>(.*?)</td>#', $phpinfo, $matches);
$error_log = $matches[1];
Note that if there is no error_log set, $error_log
will return:
<i>no value</i>
Upvotes: 1
Reputation: 70540
The only way to get it in PHP is by installing something like ApacheAccessor
. Wouldn't call it portable though, as I've seldomly seen it installed, but wildly guessing default paths is default distro's is about your only other option.
Upvotes: 0
Reputation:
you can pull it from the ErrorLog Directive
http://httpd.apache.org/docs/current/mod/core.html#errorlog
Upvotes: 0