Avatar of Gosman
Gosman
 asked on

PHP Error logging

Is the a way of implementing a custom php error log for a particular script?

Eaxmple.

If I had a script called script.php I want to create an error log at /var/www/mydomain/script.log that only logs php errors from script.php
JavaScriptPHP

Avatar of undefined
Last Comment
owner66

8/22/2022 - Mon
PranjalShah

If you have PHP installed as Apache module, you can achieve that using .htaccess directive in conjunction with <Files>:

There is also a good article here..

http://faq.1and1.com/miscellaneous/14.html
<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>

Open in new window

owner66

Towards the bottom of THIS PAGE, there is an excellent tutorial and examples on how to setup custom errorlog function using set_error_handler() in PHP.
ASKER CERTIFIED SOLUTION
perntoft

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
owner66

was my suggestion helpful?
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy