Welcome Guest, Not a member yet? Register   Sign In
How to suppress error output
#1

[eluser]lkagan[/eluser]
As I understand it, the only 'supported' way to suppress error output is by changing the value of error_reporting. This is certainly a deal-breaker. Disabling all error reporting on a live server is not a good practice.

How can I suppress the display of errors reported by CodeIgniter and (as strange as it may be) have it pay attention to my settings in php.ini or directory specific php settings via .htaccess?

Thanks in advance.

Larry
#2

[eluser]Sean Murphy[/eluser]
Hi Larry,

There are two configuration settings in particular you want to pay attention to: error_reporting and display_errors.

On a development server you generally want to have errors printed to the screen. In fact, you want ALL errors, warnings, and notices to show up. To do so you set error_reporting to E_ALL or 8191, and display_errors to true or 1.

On a production server you certainly don't want any errors printing to the screen, but you DO want errors logged so you can review them. In this case you likely only care about the more serious errors. Not only that, if you log notices in addition to errors and warnings your logs are liable to get quite large. So, set error_reporting to something like E_ERROR | E_WARNING | E_PARSE, display_errors to false or 0, and make sure you have error logging set up correctly.

Hope that helps!
#3

[eluser]lkagan[/eluser]
Thanks for the info, unfortunately it doesn't help. I'm aware of the php settings and use them quite often. As personal preference, I keep display_errors off and log all errors in dev, staging and production environments.

Unfortunately, CodeIgniter ignores the display_errors setting. That's my issue. I won't deploy a CI app to a production server unless I have control over the level of error reporting (which I do) and the method of reporting (which I don't). For some reason, CI ignores those php.ini settings. I see where error_reporting is set in index.php and I can modify that, but the display_errors setting is hiding from me.

Thanks anyway.
#4

[eluser]Derek Allard[/eluser]
I'm not sure I'm following. You want CI generated errors suppressed, but PHP and database errors enabled?
#5

[eluser]lkagan[/eluser]
I just started working with CI today so I'm not sure about DB errors and how CI handles those.

What I'm saying is that CI obviously has custom error handlers (think set_error_handler()) that ignore the display_errors php.ini setting. I just want CI to use the settings I use in php.ini.

It's seems absolutely foolish to essentially overload the built in error handling and ignore php.ini settings.

I'm hoping that I'm just being ignorant here and someone can clue me in, because I do like many things about CI.
#6

[eluser]Derek Allard[/eluser]
Sorry, its been a long day for me. Bear with me ok, because I'm sure we can help get this sorted out.

That said, I just don't understand what you want. Are you trying to have PHP errors on and CI errors off?

CI will report PHP errors, so if you have PHP errors suppressed, then CI won't report them.
#7

[eluser]lkagan[/eluser]
I have yet to come across any CI-specific errors. I've only encountered a traditional php error. Instead of the error showing up in my error log as it's supposed to, it's being pushed out to the browser in a pretty little CI design.

My php.ini file has display_errors = 'off' and error_log = '/var/log/php'. I should NOT be seeing any errors in a browser....... yet I am.

Do you know what I mean?
#8

[eluser]rhkdmbd[/eluser]
[quote author="lkagan" date="1187674084"]I just started working with CI today so I'm not sure about DB errors and how CI handles those.

What I'm saying is that CI obviously has custom error handlers (think set_error_handler()) that ignore the display_errors php.ini setting. I just want CI to use the settings I use in php.ini.

It's seems absolutely foolish to essentially overload the built in error handling and ignore php.ini settings.

I'm hoping that I'm just being ignorant here and someone can clue me in, because I do like many things about CI.[/quote]

Are you talking about the error messages you see when you have a database error (like a bad query or something)?

I find that they tend to stop a script executing, which was messing with my own error handling.

If you look in application/config/database.php

You want to set:

Code:
$db['default']['db_debug'] = FALSE;

Sorry if this isn't what you were getting at, just trying to help Tongue
#9

[eluser]lkagan[/eluser]
Thank you for trying to help but it's not as complicated as you're thinking (not that the db error you're talking about is complicated).

See this URL: http://codeigniter.larrykagan.com/ (will only be there for a short time)

You'll see the output of the value of my display_errors flag. It's false. Then, you'll see, uh, an error output!

Here's the code I used at the top of that file:
Code:
<?php
$display_errors = ini_get('display_errors') ? 'on' : 'off';
echo "display_errors = $display_errors";
asdf
?>

So you see, I told php not to display any notices, but CI ignores it.
#10

[eluser]Derek Allard[/eluser]
Open up index.php

What does line 12 say?




Theme © iAndrew 2016 - Forum software by © MyBB