Solved : php log files set error levels

All your question about php
Post Reply
mister_v
Posts: 188
Joined: Thu Mar 04, 2010 9:19 pm

Solved : php log files set error levels

Post by mister_v »

HI,

How can I set the log levels in php?

Now the logs of my webserver get filled by notice errors,
but I don't need them.
Last edited by mister_v on Thu Apr 28, 2016 5:47 pm, edited 1 time in total.
chris
Site Admin
Posts: 194
Joined: Mon Jul 21, 2008 9:52 am

Re: php log files set error levels

Post by chris »

You can set what need to be logged by adapting error_reporting in php.ini.

Code: Select all

/etc/php.ini
or

Code: Select all

/etc/php5/apache2/php.ini

This will log all error except for notices and coding standards warnings

Code: Select all

error_reporting = E_ALL & ~E_NOTICE
and this will also not log depreciated errors:

Code: Select all

error_reporting = E_ALL & ~E_NOTICE & ~E_DEPRECATED
chris
Site Admin
Posts: 194
Joined: Mon Jul 21, 2008 9:52 am

Re: php log files set error levels

Post by chris »

Here is a full list:

E_ALL - All errors and warnings (includes E_STRICT as of PHP 5.4.0)
E_ERROR - fatal run-time errors
E_RECOVERABLE_ERROR - almost fatal run-time errors
E_WARNING - run-time warnings (non-fatal errors)
E_PARSE - compile-time parse errors
E_NOTICE - run-time notices (these are warnings which often result
from a bug in your code, but it's possible that it was
intentional (e.g., using an uninitialized variable and
relying on the fact it is automatically initialized to an
empty string)
E_STRICT - run-time notices, enable to have PHP suggest changes
to your code which will ensure the best interoperability
and forward compatibility of your code
E_CORE_ERROR - fatal errors that occur during PHP's initial startup
E_CORE_WARNING - warnings (non-fatal errors) that occur during PHP's
initial startup
E_COMPILE_ERROR - fatal compile-time errors
E_COMPILE_WARNING - compile-time warnings (non-fatal errors)
E_USER_ERROR - user-generated error message
E_USER_WARNING - user-generated warning message
E_USER_NOTICE - user-generated notice message
E_DEPRECATED - warn about code that will not work in future versions
of PHP
E_USER_DEPRECATED - user-generated deprecation warnings
mister_v
Posts: 188
Joined: Thu Mar 04, 2010 9:19 pm

Re: php log files set error levels

Post by mister_v »

I changed the value of error_reporting, but it is not working.

What do I do wrong.
chris
Site Admin
Posts: 194
Joined: Mon Jul 21, 2008 9:52 am

Re: php log files set error levels

Post by chris »

Are you sure you don't overwrite the error_reporting somewhere later in the file?

I had that problem once.
mister_v
Posts: 188
Joined: Thu Mar 04, 2010 9:19 pm

Re: Solved : php log files set error levels

Post by mister_v »

Thanks, there are indeed 2 lines with error_reporting.

I also edited the second line, and now it works.

Why are there 2 lines?
Post Reply