0

How do you turn error logging off for specific file in php?

I know that for not displaying the error you do

<?
error_reporting(0); // dont report/show errors
don't log errors; - // how to do that.
?>
4

3 Answers 3

1
ini_set('log_errors', 'off');

or in PHP.ini:

log_errors = off
Sign up to request clarification or add additional context in comments.

Comments

1

Error logging is controlled through the log_errors configuration setting, so you can turn it off with ini_set('log_errors', false) and then turn it on again at the end of the file (actually, saving the old value and reverting to that is better).

Note that this will only work for code that is executed once, not e.g. for code inside class methods.

1 Comment

Downvoter: please help me improve this answer by leaving a comment. Thanks.
0

error_reporting(0) effectively disables logging of the errors. If you want to log the errors, but don't display them, you should use

error_reporting(E_ALL); // or whatever level of reporting you need
ini_set('display_errors', 0);

2 Comments

That's the problem error_reporting(0) in my case doesn't show errors (which is what i wanted) but logs them (which i don't want)
@Adrian Does error_reporting(E_ALL) shows the errors? It seems that you have "display_errors" set to "off" and the error_reporting() function is disabled. Add var_dump(error_reporting()) to see if the value is changed

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.