I need to log Fatal-errors of my website.
I normally check error.log and debug.log files for CakePHP errors.
But I found out that PHP related fatal errors aren't logged someplace.
It is also discussed in this thread.
I checked php.ini. IT has following lines:
log_errors = On
;error_log = filename
I don't have rights to change php.ini. I can ask admin to change this, but it seems like I need to ask him every time I need a change :) I also have concerns about performance. Whether logging errors can decrease performance or not?
So I find out that I can put following two lines inside my script to log errors and change folder or file name when I need.
ini_set("log_errors", 1);
ini_set("error_log", "/path/to/php-error.log");
So I want to know where to put this lines inside my codes? Should I put it inside AppController::beforeFilter ? Or is there a better place/solution in CakePHP 2 configuration?
this is an old thread.
in the meantime with cake 2.x errors are all logged in productive mode - so also fatal errors.
trigger one and check out your /tmp/logs/error.log
but you can easily find that out looking at the core code:
https://github.com/cakephp/cakephp/blob/master/lib/Cake/Error/ErrorHandler.php#L189
There is framework defined configuration settings. You can use the Error Handling configuration class.
Here is changing fatal error behavior link, that will help you to achieve the same.
register_shutdown_function();
http://php.net/manual/en/function.register-shutdown-function.php
Related
The yeoman generators "meanjs" automagically installs a core and a user module when you do a fresh generation. My goal is to remove the user module and only use the core.
Any ideas? I considered sharing code but I'm not sure it would help.
Thanks
More Info:
The reason i'd like to remove this is because the web application I'm creating requires ZERO user management
The easiest option would simply be:
First make sure that you are able to run your code.
Delete the users folder.
Run your code, which will fail probably, and look at the errors.
Go through all the error messages and delete every link to the users module.
Note: this is applicable for MEAN version 0.4.X and above.
Currently i'm using latest version of cakephp,When i try to install it it shows the error as temp folder is not re writable.
OK it is fine we can give ch-mod rewrite permission to that particular folder. But there is a reason behind everything.
I tried to find why should we give to it , and what is the reason behind that but i can't get the answer clearly , so i'm expecting it from you , can anyone help me to understand, thanks in advance...
You’re asking why a tmp folder needs write access? Well, if you look in the folder, there are sub-folders for caching, logging, session, and tests if you run them.
CakePHP needs write access so it can write cache file, write any errors logs, write sessions to disk if you’ve configured CakePHP to save session data in your tmp folder.
I’m not sure how to explain this any clearer than, CakePHP needs write access to the tmp folder to, erm, write files.
Documentation says:
Make sure that this folder exists and that it is writable, otherwise the performance of your application will be severely impacted. In debug mode, CakePHP will warn you if it is not the case.
See: http://book.cakephp.org/2.0/en/getting-started/cakephp-folder-structure.html
Today I was moving a CakePHP app that I made on windows to my new macbook. For some weird reason one model doesn't load properly. Other models do load properly though, which confuses me...
I got this error:
Fatal error: Call to undefined method Locale::getLocale() in /server/cakephp/app/Controller/AppController.php on line 59
That line is just calling a method in my Locale model that I have.
So I tried to see what $this->Locale looked like with this code:
die(pr($this->Locale));
And this was the result:
Locale Object
(
)
I don't know why, but apparently I get an empty object. I tried removing the Locale.php file to see if CakePHP would automatically use AppModel, but it still becomes an empty object. So I tried searching if I have some empty class called Locale somewhere, but I couldn't find it.
Please help, this is so frustrating!
I cloned the CakePHP library from git yesterday, maybe that's useful information? Could it be that Locale has suddenly become a reserved word?
Permissions maybe? I've also had troubles in the past with hidden .files when moving cakephp apps, worth checking. I'm guessing that git handles both correctly though.
I am using Cakephp, but I am unable to log the info and errors in log files because it doesn't work with Configure::write('debug',0) and I can't set it to 1 or 2 or 3 on my production system.
I tried log4php, but it also not helps me as I want to log different error types in different files. Can anyone suggest me some other plugin for logging which Cakephp supports?
You can write to the logs without debug being set to 0, just write to the log using:
$this->log("I am testing the logging without debug being turned on!", 'debug');
You can get more information here.
http://book.cakephp.org/view/1194/Logging#!/view/1195/Writing-to-logs
I'm running into a problem with GroupsController::build_acl()- http://book.cakephp.org/view/647/An-Automated-tool-for-creating-ACOs
It's taken me a while to track down the bug and now I've found it I'm not sure how to work around it.
Symptoms:
Not all methods for NodesController (defined by me) are returned.
Probable reason:
build_acl() imports a 3rd party plugin that also has a NodesController and a subsequent App::import() doesn't overwrite it.
I'm about to try two runs of the build, one with the plugin code commented out, but a more durable solution would be preferred!
I need a way to either drop an imported controller or force a re-import while remaining in scope.
you can not do what you want to do, think about straight php for a while. once you have used include('some/file.php'); how do you un-import it? you cant.
now the reason why you cant overwrite it is once again down to php. what happens if you run
<?php
include('some/file.php');
include('some/file.php');
?>
you will get errors about the class being defined already.
Cake is stopping this from happening, so the only (and correct way) is to not have 2 controllers with the same name. you can name them what ever you like and use the router to map to nice urls.
Turns out the plugin was redundant and not called anywhere in the application and would have broken it if it was as a class redefinition error would have ensued. After removal of the files everything worked okay.