Cakephp log all errors in production server - php

I have gone through this link but it didn't help me.
how do you log php errors with cakephp when debug is 0
I need to log all errors when the debug is 0. I am using cakephp2.0 . What settings I should give in core ? I tried with define('LOG_ERROR', 2); and made an error intentionally but it is not inserting into any log files under cake/app/tmp/logs folder.
And is this depends on php.ini settings ?

Related

http error 500 aws bitnami wordpress hosting [duplicate]

I am having an issue when I have a php application that is returning an internal server error (500) however nothing is showing up in the error log.
Now I know there are error with what I am trying to run, I know I have missing some files and what not but something should show in the apache error log (otherwise how are I supposed to know exactly what I am missing).
I created a test script is errors it in under the same vhost configuration and those error show up fine so everything seems configured right as far as php/apache. Are there certain php errors that does show up in the error log (php is configure to display any type of notice, warning, , error, fatal error, etc...)?
This is running on ubunut 10.04 with the standard apache and php from the ubuntu repo with apt-get.
Scan your source files to find #.
From php documentation site
Currently the "#" error-control operator prefix will even disable
error reporting for critical errors that will terminate script
execution. Among other things, this means that if you use "#" to
suppress errors from a certain function and either it isn't available
or has been mistyped, the script will die right there with no
indication as to why.
Copy and paste the following into a new .htaccess file and place it on your website's root folder :
php_flag display_errors on
php_flag display_startup_errors on
Errors will be shown directly in your page.
That's the best way to debug quickly but don't use it for long time because it could be a security breach.
If you still have 500 error and no logs you can try to execute from command line:
php -f file.php
it will not work exactly like in a browser (from server) but if there is syntax error in your code, you will see error message in console.
Maybe something turns off error output. (I understand that you are trying to say that other scripts properly output their errors to the errorlog?)
You could start debugging the script by determining where it exits the script (start by adding a echo 1; exit; to the first line of the script and checking whether the browser outputs 1 and then move that line down).
In the past, I had no error logs in two cases:
The user under which Apache was running had no permissions to modify php_error_log file.
Error 500 occurred because of bad configuration of .htaccess, for example wrong rewrite module settings. In this situation errors are logged to Apache error_log file.
For Symfony projects, be sure to check files in the project'es app/logs
More details available on this post :
How to debug 500 Error in Symfony 2
Btw, other frameworks or CMS share this kind of behaviour.
Here is another reason why errors might not be visible:
I had the same issue. In my case, I had copied the source from a production environment. Hence the ENVIRONMENT variable defined in index.php was set to 'production'. This caused error_reporting to be set to 0 (no logging). Just set it to 'development' and you should start seeing error messages in apache log.
Turned out the 500 was due to a semi colon missing in database config :-)
Another case which happened to me, is I did a CURL to some of my pages, and got internal server error and nothing was in the apache logs, even when I enabled all error reporting.
My problem was that in the CURL I set
curl_setopt($CR, CURLOPT_FAILONERROR, true);
Which then didn't show me my error, though there was one, this happened because the error was on a framework level and not a PHP one, so it didn't appear in the logs.
You need to enable the PHP error log.
This is due to some random glitch in the web server when you have a php error, it throws a 500 internal error (i have the same issue).
If you look in the PHP error log, you should find your solution.
see here in the doc of how to enable it in the php.ini
Be sure your file permissions are correct. If apache doesn't have permission to read the file then it can't write to the log.
What happened for me when this was an issue, was that the site had used too much memory, so I'm guessing that it couldn't write to an error log or displayed the error. For clarity, it was a Wordpress site that did this. Upping the memory limit on the server showed the site again.
SOLVED
I struggled with this and later on, I realized that I was working on PHP 5.6, so I upgraded to PHP 7.0, then I released there were comments placed by git for conflicting codes. I found something like this in my code <<<<<<<< But solved it.

Errors in plugins make a 500 server error with no error message on screen or in log

I have an issue with errors generated in WordPress plugins that is making development difficult for me.
If I trigger an error in a normal PHP file like so:
trigger_error("an error occurred", E_USER_ERROR);
It works fine and I will get the error displayed on the page. However, if I try the same in the code of a plugin the server generates a 500 error in browser and does not display the error.
In addition, it also does not log any error in the PHP-FPM or Nginx log file when occuring from plugin code. This is making development extremely difficult as when I get an error I have no information to go on.
As this is working fine in standalone PHP I am assuming it must be WordPress related.
I have debugging enabled in wordpress. My stack is as follows:
Ubuntu 16.04
PHP 7.0.4
Nginx 1.10.0
MariaDB 10.0.24
The file ownership is user:www-data. Directories are 775 and files are 664
Errors are enabled in the PHP conf files and I can see errors fine with standalone PHP pages, it is just happening on the server in context of errors happening in the WordPress plugins PHP pages.
This is very frustrating as I cannot see why this is happening. Does anyone have any insight that could help me figure this out?
EDIT
To be more clear here is what I have in wp-config to enable debugging:
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
Other debugging values are defaulted to true so this should be all I need.
Curiously I have just noticed that error_log() does not do anything inside a WordPress file while trigger_error() will cause the 500 error.
This feels like some sort of permission based error but I am not sure what. I really need some help with this as development in this circumstance is practically impossible without any error text.
Wordpress disables error reporting by default. You can enable wordpress debug mode by setting to true the WP_DEBUG constant in wp-config.php.
Here you can find more detailated instruction:
https://codex.wordpress.org/Debugging_in_WordPress
The problem was caused by a plugin "Wordpress CSV Importer". I do not know why but removing it made debugging work again.

CodeIgniter migration from 1.7.2 to 2.0 returns blank page

I have the task to migrate a codeigniter webpage from 1.7.2 to 2.0 ( 2.2 ) and then I need to migrate it to 3.0.
I followed this guide.
After I did everything I uploaded it to the ftp and now I am getting a blank page.
I think I've got all things done as by the tutorial but even if I have missed something I at least need an indication for that. But I am getting nothing but a blank page.
I enabled error_reporting - nothing.
Configured the log_threshhold to 1, and again - nothing.
It seems that you got error 500 or something, so make your error reporting (not only on codeigniter) on on your web server or htacces file by adding
php_flag display_errors on
and check your php error log if is available for you.

Codeigniter Blank Screen - Failing to load welcome class

I am in the process of migrating codeigniter from centos to ubuntu and after moving the files, adjusting the config files, etc, I am getting the white screen of death. Debugging it, the code seems to die in CodeIgniter.php at
$CI = new $class();
where
$class = welcome
I have confirmed the MySQL is installed and running, both in PHP and on the command line. Additionally, I can't find codeigniter complaining about any errors in either my apache error logs or the codeigniter ones at application/logs. This is despite setting the logging threshold to 4 and setting display errors to true.
the only solution for this issue to find the php error logs,
check it on /var/logs/apache2/errors.log or if you use ssl /var/logs/apache2/ssl_errors.log
this is the default paths for php error log
please check your php error logs for getting the error message.
There's 3 solutions to know where's the problem.
1- Codeigniter offer logs for configure it
go to application/config.php
Change $config['log_threshold'] = 2; //for debug messages
Each request you can find the log messages in
application/logs/..
or
system/logs/..
Don't forget to switch it off after fix your issue by change it to 0 or 1 for display error messages only.
2- Or you can Enable development mode but i prefer the first solution.
if you want to switch to development mode edit index.php in the main project files and change ENVIRONMENT definition to 'development'
this option show errors on the site front.
3- Or you can check the PHP log errors in
/var/log/apache2/error.log
or
/var/log/apache2/ssl_error.log
if you using https

How to configure PHP to display detailed errors instead of error 500 page?

I have a PHP application deployed on my IIS hosting and I am always getting generic IIS "error 500" pages insteady of detailed error pages.
I understand I need to modify some php.ini file (from this question).
It seems that display_errors is set correctly:
echo ini_get('display_errors');
outputs 1.
I have also tried setting display_errors and error_reporting in the function that causes the error (I know the particular function is the problem because I manually modified it).
function sendEmail( $aForm, $sFile = 'messages.tpl', $sTargetEmail = null ){
error_reporting(E_ALL);
ini_set('display_errors', 'On');
//rest of the function
EDIT: I know I should have set these values in some php.ini file - how can I specify php.ini values on a shared hosting, when I have only access to my app folder via FTP?
How can I identify the error details?
It looks to me like you do have 'display_errors' turned on but your hosting provider is redirecting your 500 error page to a custom page which doesn't display the errors. Not a great set up but I would contact your hosting provider in the hope that they can shed some light on the problem. It is possible to have .user.ini files on IIS see
see http://learn.iis.net/page.aspx/745/enable-per-site-php-configuration-on-iis-60-and-iis-7-and-above/
again only your hosting provider would know if this is set up.

Categories