What are the possible logging plugins for Cakephp? - cakephp

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

Related

How can i see errors with debug false?

I have an issue, i need to be able to see the php error when debug mode is set as false on production environment.
I currently see the internal error message but i would like to see the php error in case things break.
How can i do this? I don't want to have the debug kit activated as well.
/**
* Debug Level:
*
* Production Mode:
* false: No error messages, errors, or warnings shown.
*
* Development Mode:
* true: Errors and warnings shown.
*/
'debug' => false,
In the Logs dir you can always view the error.log.
I usually spit out the error.log on a page that has restricted access, cause I cant always get on the filesystem and its just faster and easier for others aswell.
Restricted DebugKit access
Depending on the security requirements of your application, you can implement some form of check to turn on debug mode while in production. For instance, a custom key + IP restriction.
So you can check to see if `$_GET['key'] is equal to your key AND the IP matches your machine. If so, turn debug on, otherwise, leave it off. This will allow you to much more easily debug your live application.
You are opening yourself a bit to potential concerns (though I'm not a good enough hacker to know any particular ones). But if you're doing banking level software, or storing any type of PCI-compliant data, you should probably not do this. Otherwise, it's a good solution.
Or, you could simply turn on debug kit if logged in as user with a specific role.
CakePHP Logs
As others have mentioned, you can use the internal Cake Logs via accessing them directly or, as Alex points out in another answer, display the error log on a page with restricted access.
Third Party Logs
Companies like PaperTrailApp make sorting through your logs very nice and easy.
If you want there is a plugin called error email cakephp, I use in my projects you install and define what kind of errors he might send you an email , it's very good and works on cakephp 3. You can find the project on github, its very documented.

Umbraco angular errors

We have a project running Umbraco 7.5.9
We have suddenly started to get the following errors when loading Umbraco and opening various document types
Failed to load template: views/components/umb-folder-grid.html?umb__rnd=7.5.9.884162080
The errors come from /umbraco/lib/angular/1.1.5/angular.min.js
Is this a server setting that is causing this? The error has suddenly started appearing in several applications
Thanks
Check your project path whether Umbraco\Views\components\umb-folder-grid.html files exist?
It seems like you are missing that file - maybe accident delete it or did not include it when publish
Check your dev tools network tab and look for the call for the umb-folder-grid.html file.
It should come with a 200 response, but in your instance it may be 404ing.
I found that this file is requested when I go to the Media section of Umbraco.
If the file is 404ing, open up the location of the file in a separate tab and see if anything is being returned. If there is nothing there, check that your server does have the file on it.

What can I do with generated error logs?

I'm currently working on a web application which generates daily error (and non error) logs.
The current system outputs a log per task to a text file, and outputs critical errors as well as "start" and "finish" type messages to an email account.
The current workflow is as follows: scour the email box for errors, then go and find the .txt file to look at the associated errors and find the cause.
There are around 30 txt files split across about 5 servers.
This system was set up before me, but I'm looking for any advice on how to deal with the situation.
I have control of the script forming the error logs so can do pretty much anything - but I'm lost where to start: I'd considered some kind of web facing dashboard tool, maybe output the files to RSS or something?
Are there any external or internal tools I should be using?
Of course you may use the SQL Server Reporting Services or review this comparison table, there are some packages which may support SQL Server but they may be overwhelming for your task.
It's not really clear what your problem is or what you want to do, but if I understand correctly, your biggest problem is that some messages are logged to a log file but others are sent by email. Therefore, there is no single location that has all error messages in it and that makes analysis and troubleshooting difficult.
The best solution would be to use a logging framework that supports multiple logging destinations (file, DB, email) and severities. That would allow you to specify a configuration like "all errors are logged to a text file and critical ones are also sent by email", so you can ensure that you have everything in one place for general analysis but critical errors are also handled with priority.
You didn't mention what programming language you use, but assuming it's .NET-based then log4net and Enterprise Library are two common frameworks and there are many questions about them here on SO. Googling should give you a good idea of the pros and cons for your situation. If you're using a different language then you can look for the equivalent package: log4j (Java), logging (Python) etc.

CakePHP from localhost to remote server - blank page

i am trying to figure this out for a long time now, but so far no luck, maybe somebody can help me.
I have a 2.2.2 cakephp installed on my computer (localhost) and everything works perfectly. But now i want that same project to be online on remote server. I upload everything, set mysql path but i get a blank page when trying to access the site.
If i upload a fresh cakephp it works, but my project doesnt. The debug is set to default, think that should be 2? I also deleted files in cache/tmp, but still no errors or anything, just blank page.
Any info would be helpful, thank you.
I hate when that happens :). Usually it does if there is an error somewhere and you can't see it because the errors are turned off, so you should call phpinfo() and see if display_errors is on. Changing the debug mode doesn't work every time since display_errors is set from php.ini.
Unfortunately, if this is the problem and you don't have access to edit the php.ini file, you might need to ask the hosting provider to change it and restart the php service.
You can also try this: error_reporting(E_ALL)
I uploaded changes to my cakephp website and discovered that all actions for a particular controller returned a blank page. I discovered what the error was and was able to reproduce it with another controller.
The problem was that in the first line of my controller file I had a space before the opening php tag.
One space cost me hours.
Just uploading all files won't cut it. Make sure you work through this checklist:
First and foremost, check the error log file located under app/tmp/logs/error.log, this usually holds some very good pointers as to what is wrong.
Make sure you have uploaded the app/Config/database.php file with the proper details. Local installs usually have user root without password. Online servers (obviously) do not!
To that extent, also make sure you actually have a database with your hosting provider (either your host sent you the info or you need to create it yourself using their control panel).
Make sure you also uploaded all .htaccess files (the one under the root directory and /app and /app/webroot), some FTP programs don't show this "hidden" file by default.
If all else fails, contact your hosting provider for further support as they usually have access to more verbose server logs that can also hold clues.
The real problem was only the coding I used in notepad++. All my files were encoded with UTF-8, but they should have been UTF-8 without BOM. After I changed it to UTF-8 withot BOM, everything started to work perfectly.

Logging PHP fatal-errors in CakePHP system

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

Resources