Welcome Guest, Not a member yet? Register   Sign In
Logging Threshold and excluding PHP errors
#1

[eluser]deadelvis[/eluser]
Hi,

Is there a way to prevent PHP errors from being written to log files? Or at least certain PHP errors or from certain function calls?

I ask this because I use log_message() on all my functions to keep track of problems that might occur. Trouble is that I need to do some scraping using the DOMDocument object and SimpleXML...

Code:
$html = new DOMDocument();
@$html->loadHTMLFile($url);

... which returns hundreds of error messages (due to parsing bad hmtl). Although thse errors are suppressed from output by the @, they are all logged, filling up the log files very quickly.

Any ideas appreciated.
#2

[eluser]Seppo[/eluser]
You can shut the error_reporting and then reenable it...

Code:
$error_reporting = error_reporting(E_NONE);
$html = new DOMDocument();
$html->loadHTMLFile($url);
error_reporting($error_reporting);
#3

[eluser]deadelvis[/eluser]
Thanks for the tip, but it doesn't work. Errors still get added to the log:

Code:
ERROR - 2008-06-22 18:45:22 --&gt; Severity: Warning  --&gt; DOMDocument::loadHTMLFile() [<a href='function.DOMDocument-loadHTMLFile'>function.DOMDocument-loadHTMLFile</a>]: End tag : expected '&gt;' in http://www.mydomain.com/mypage, line: 60 scrapers.php 116
ERROR - 2008-06-22 18:45:22 --&gt; Severity: Warning  --&gt; DOMDocument::loadHTMLFile() [<a href='function.DOMDocument-loadHTMLFile'>function.DOMDocument-loadHTMLFile</a>]: Unexpected end tag : scri in http://www.mydomain.com/mypage, line: 60 scrapers.php 116

etc... etc...

I tried all these options (E_NONE doesn't seem to be valid, 0 is the corresponding value it seems):

Code:
$error_reporting = error_reporting(0);
$error_reporting = error_reporting(E_ALL ^ E_WARNING);
ini_set('error_reporting', 0);

In my config the threshold is:
Code:
$config['log_threshold'] = 1;

No clue why CI is still saving PHP warnings to the log. Any other ideas?




Theme © iAndrew 2016 - Forum software by © MyBB