开发者

Log errors in one of my php script to specified logfile [closed]

Closed. This question is off-topic. It is not currently accepting answers.

Want to improve this question? Update the question so it's on-topic for Stack Overflow.

Closed 10 years ago.

开发者_开发问答 Improve this question

If I run following php file

<?php
$str = 'he;
echo $str;
?>

it will log a parse error to standard apache log file. I can specify a logfile in php.ini but that would change logfile for all php scripts.

Is it possible to log errors from specific script to a particular log file?


You can achieve that using .htaccess directive in conjunction with <Files>:

<Files something.php>
    php_flag log_errors on
    php_value error_log /path/to/your/error.log
</Files>

<Files something_else.php>
    php_flag log_errors on
    php_value error_log /path/to/your/other_error.log
</Files>

Also, make sure you have PHP installed as Apache module, else it won't work.


In PHP/5.3.0 and greater, you can create [PATH=] sections in your php.ini file.

You mention something about Apache. If you are running PHP as Apache module, you can use the php_value directive inside standard Apache containers like <Files>.


Since PHP 5.3 it is possible to bind a setting in php.ini to a certein path through usage of PATH.

this section allows you to define a set of php.ini directives that will take effect when a script runs from the named path.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜