I'm having some problems getting zf2 to log errors or report them under some circumstances.
Some errors will be reported to screen and the error.log but others are not and just result in a blank screen. There doesn't appear to be any reasoning behind what does get displayed and what doesn't.
I have error reporting enabled in my php ini set to E_ALL and I have added
'display_not_found_reason' => true,
'display_exceptions' => true,
to my module config, and I have also tried setting the error reporting values directly in the index.php
At the moment im trying to use doctrine and just getting a blank screen...
https://packagist.org/packages/webino/nette-debug
Link listed above is one of the most useful debug tools I've found so far for zf2. It picks up 99.9% of the errors and the configuration allows you to log it to a specific log file in your directory. However there is that .1% that it doesn't catch and that generally does go through to the syslog so you should be able to find out more details there. Just make sure you initialize the nette debug module as the first module in the stack.
Hope this helps you, I got really sick and tired of those issues too up to the point where where I found nette.
Related
I have two Google App Engine Standard env services within a project. The second service (PHP 5.5) is fine, but the 'default' instance has disappeared from Stackdriver Error Reporting after switching the runtime to PHP 7.2 (I think... I'm not definite on the point it disappeared).
'Default' is still available in Stackdriver > Logs Viewer, but while this displays 500 errors, it doesn't provide details of the exception.
'Default' service is missing from the Stackdriver > Error Reporting > 'All services' select input, even if I set the time frame prior to the point it disappeared, much like its been deleted from Stackdriver.
I've worked through https://cloud.google.com/error-reporting/docs/setup/php and added everything relevant except ...
auto_prepend_file='/project-dir/vendor/google/cloud-error-reporting/src/prepend.php'
... as there's nothing in the docs to suggest what /project-dir/ is. I tried setting this to ...
/VENDOR-PARENT-DIR/vendor/google/cloud-error-reporting/src/prepend.php
and
/PROJECT-NAME/VENDOR-PARENT-DIR/vendor/google/cloud-error-reporting/src/prepend.php
... either of which display an error in the browser after deploying, which I assume is related to an error within php.ini. Taking this line out of php.ini and re-deploying resumes normal service.
Is anybody able to provide some pointers, please? I've got a 500 in QA which I can't replicate locally and I'm fumbling in the dark with no error reporting on the GAE instance.
Thanks
Please keep in mind that only errors containing a stack trace will be processed to Stackdriver Error Reporting.The service name will not appear on the dropdown if no log containing a stack trace is generated.
However, you can review all logs on Stackdriver Logging page.
Review the following documentation for more details.
Also review the following documentation for more details on Stackdriver Trace.
So I've just spent quite some time on something that should have been very quick to fix.
I'm on a local environment, with debug set to true. I was working on a php file which implements the Jsonable interface, and I got the compatibility a bit wrong. Unfortunatly, when I ran this file, it simply showed a 500 error and a completely blank, white page, without any errors.
I checked my error log, and that didn't have any errors in it (relating to this issue) either.
I found online that setting debug to true in Laravel hides sets display_errors to 0. I quickly did a ini_set('display_errors', 1) in my called controller and I got the fatal error message I was looking for!
My question is:
How can I display these fatal errors etc (not exceptions) in Laravel when debug is true, without specifying ini_set('display_errors', 1) in all my controllers?! Why does Laravel hide errors when in debug mode anyway?! It's very frustrating having an error which isn't displayed (even when in debug mode), and isn't logged!
Any help is appreciated.
I have a CodeIgniter PHP app running on a Heroku Cedar instance.
We are running a PHP app and we need to log errors, but NOT print them to the screen. No matter what I do, the errors are printing to the screen, which is not safe for production.
Here is the PHP code which works on my local environment and everywhere else (besides Heroku):
error_reporting(E_ALL); #we care about all errors
ini_set('display_errors',0); #but DONT print to screen
I have seen this document which suggested I try adding a custom CodeIgniter logging class, which did not work.
I also added a phpinfo() to the app to check if somehow my settings were being overridden downstream, but it shows that display_errors is set to "Off".
So why am I STILL seeing errors printed on the screen?
It turns out that CodeIgniter 2.x has some completely asinine error handling in which they use a custom error handler to ignore the developers configurations. Apparently this is fixed in v3.
I was able to fix it by just commenting out the custom error handling, which for me was located in in CodeIgniter.php, line 72...
//set_error_handler('_exception_handler');
Or the best solution of all: don't use CodeIgniter in the first place.
I want to log some messages from my php application in the apache error logs. But I would like this to happen only in the non-production environments.
I found that php has error_log to log messages to the error log file but how do I control it to only log if my application is running in the non-prod environments.
Also, I found that there is trigger_error which takes a error type parameter. And the error_reporting setting in php.ini can then decide which error types are actually logged. So, while in dev, I have error_reporting set to E_ALL , it is more restricted in production. So, now I can use trigger_log and always log at E_USER_NOTICE. This would mean that my message is only shown in the dev log files but not in the production log files.
However, trigger_error also produces a stack trace with every log which is a bit unnecessary for me. How can I disable this stack trace.
Also, am I doing things the right way. How do people generally handle this problem.
Edit:
I am not trying to suppress error messages. I am trying to provide more debug messages in dev. Things like "Request came with following parameters", "step 1 done", etc. This is really not required in production.
If you want just custom messages sent into error log manually, log_error() is the function you are looking for.
Firstly, suppressing error handling is not a good idea - errors have a huge impact on your application performance - and suppressing error reporting does not eliminate the slowdown.
There is no 'trigger_log' in PHP.
The build in error handling in PHP does not generate a stack trace - you must have a custom error handler installed. You need to find it and amend the code if you want to change it's behaviour.
Using 'trigger_error' to record debug events is a very bad idea.
I would like to log PHP errors on a CakePHP site that has debug = 0. However, even if I turn on the error log, like this:
error_reporting = E_ALL & ~E_NOTICE & ~E_DEPRECATED
log_errors = On
it doesn't log errors.
The problem is that even for a parse error that should cause the CakePHP environment to not load completely (I think), it still blocks the error from being logged. If I set debug to 3, it logs to the file without issue.
I am using CakePHP 1.2. I know this is apparently made easier in 1.3, but I'm not ready to upgrade.
Another way to keep track of and log errors would be to use the Referee plugin as it provides a way to arbitrarily log and catch all (including fatal) errors that occur during exection.
define('LOG_ERROR', 2); in core.php
PHP should log errors to its own logfile, regardless of what CakePhp is doing.
Look in /etc/php.ini file (or wherever yours lives) and search for error_log. This will show you where the PHP log resides on your system.
There is a bug in CakePHP 1.2-1.3 where PHP errors/warnings are suppressed in view code when debugging is disabled.
In the file cake/libs/view/view.php on line #664 it reads
#include ($___viewFn);
But the # directive suppresses errors for the entire view handler. Instead it should be:
include ($___viewFn);
Which allows PHP errors/warnings to be generated in view code and subsequently get logged. Once I changed this and had the right logging settings in core.php I was finally able to get complete logs in production.
Sometime the reason could be very different. For example the framework you are using may have its own internal caching module which keeps the value in buffer while you keep on trying. Check whether duplicate copies are getting generated or not. Typically those files would be named as filename.ext.r123 and so on.