I have used codeigniter framework.Have used its log part.
I had a query regarding configuring logs in the application.
As per the documentation they say that we can configure in app/config/php and filter the logs as debug,error or info messages.
But even after doing that, I am not able to filter the logs.
Wanted to know the reason for this or am i missing something.
Help would be highly appreciated.
You need to follow the following steps to keep log file.
Change the following line of your application/config/config.php file
$config['log_threshold'] = 4;
instead of
$config['log_threshold'] = 0;
This change will produce a log file in your application/logs directory with current date as file name.
Now if you want to write your custom log in this log file then write the following code:
log_message('ERROR','YOUR_MESSAGE_HERE');
Here you can use 'ERROR', 'DEBUG' etc.
Hope this will help you.
Related
I am little bit confused on how routes work in codeiIgniter. I have set up this following route
$route['myfirstest'] = 'Blogs';
I then set up a php file called blogs.php under the application/controllers directory
When I run the following URL
/code_igniter/index.php/myfirstest/hello/hello
I get a 404 message
However when I run this following URL
/code_igniter/index.php/blogs/hello/hello
It works find
Can anyone please help me figure this out..Maybe I am not getting the whole route thing correctly..
I think this will work for you
$route['myfirstest'] = 'Blogs';
$route['myfirstest/(:any)'] = "Blogs/$1"
This will also work for you.But I don't think this is your real purpose.
$route['myfirstest/hello/hello'] = "Blogs/hello/hello";
If you want any value inside hello function you can write this way
$route['myfirstest/hello/(:any)'] = "Blogs/hello/$1";
Remember for 2nd and 3rd solution you also need to write
$route['myfirstest'] = 'Blogs';
I recently moved my website from one server to another. My index.php file uses the smarty template system to load multiple pages based on the URL. However, one specific page is loading blank now.
I don't necessarily need help fixing any coding issue, I need help finding the error.
There's no PHP error that displays and the server doesn't give a 403, 404, 500, or any other error response that I can see. Can anyone offer suggestions on how to find what's causing the error?
Perhaps adding something to the PHP file to display every error or searching the server logs to see what's causing the error to occur. As of right now, I can't necessarily narrow it down to a specific file, much less a specific line. Any suggestions on what I should add or where I should look?
I'm open to adding whatever to the PHP file to trace the error, using command-line/shell to locate log files, using Perl to track down the error, and so on. Anything will be greatly appreciated!
EDIT 1: This is on a Linux/CentOS servers that's running cPanel/WHM.
EDIT 2: After following Tim's advice below, it appears that the error is coming from this line:
$app->map('/panel/ajax', $auth('member'), function () use ($app) {
Here's the line in a bit more context:
$app->flash('restore_panel_filters', '1');
$app->redirect($redirect);
})->via('GET','POST');
$app->map('/panel/ajax', $auth('member'), function () use ($app) {
$req = $app->request();
$user_id = $app->view()->getData('user_id');
Any idea what would be causing this to happen?
I've got a Silverstripe 3.1 site in development and want to write messages to the default log file - silverstripe.log
This is what we use to output variables or messages to the screen:
Debug::show($variable);
Debug::message("Debug message goes here");
What is the simplest way to output these to the silverstripe.log file? I've been looking through the documentation and can't find the correct approach: http://doc.silverstripe.com/framework/en/topics/debugging
You could do the following:
in mysite/_config.php
SS_Log::add_writer(new SS_LogFileWriter('silverstripe.log'), SS_Log::WARN, '>');
in your code:
SS_Log::log("Dammit, an issue with variable ".$var, SS_Log::WARN);
More at http://doc.silverstripe.com/framework/en/topics/error-handling
Also reading the code in framework/dev/Log.php will give you more insight on how priorities work.
PS: ensure to define 'silverstripe.log' in a folder writable by the apache user
The simplest solution is actually pretty close to your original attempt.
Debug::log("output");
This will output to a debug.log file in the site root.
How can I print out some debug output, like the contents of an array variable? I'm using cakephp and eclipse and can't seem to be able to do this. I am not talking about logging errors, just print some variable value. It might be obvious and really easy to do, but I can't find a way to do it.
Thank you
There are no dumb questions for someone learning. So here are your options :
Anywhere in your code, place the following statement debug($var);.
This works in Controllers/Views and Models as well.
Alternative: use CakeLog::write(LOG_DEBUG, "..."); to log debug
values
To be complete, one should install the very helpful DebugKit plugin. Get it from here
First check in your core.php file inside config folder ..
debug mode is 2 or not..
Configure::write('debug', 2);
and you can print data , array ,
like this:-
debug($data);
pr($data);
print_r($data);
we have debuging kit also for cakephp, By this you can see your request, session, $this->data values,, url,
All you have to do is to use cakephp debug function like
debug($arrayname);
Before that you have to set debug mode to 2 at core.php under app/config folder
Here is more detail about the debug
I have created a test module name Mytest. While saving values from the module, I am getting a blank page and it saying "Sorry! Attempt to access restricted file. " . Do anyone know, why this happening. Any help on this is really appreciating.
The most likely cause for the vTiger error “Sorry! Attempt to access restricted file.” is the $root_directory value in the ‘config.inc.php’ is incorrect or misspelled.
In order to correct it follow the steps below:
Go to your vTigerCRM directory
Open “config.inc.php” with your favorite text editor
Go to line 86 and adjust $root_directory value to correct vTiger
directory. Note, that the directory must end with /. It should look
something like this – $root_directory = ‘/var/www/vtigercrm/’;
Also there is a problem with cache memory. So do check your cache file for template files. For that go to your vTigerCRM directory.
Then Go to Smarty->templates_c.
Here you will get list of cache files. Delete this file and check weather your problem is solved or not.
Don't worry about deletion of this file.
When trying to include files from your custom module, you will get these messages because Vtiger thinks you are including these files from a location they find rather unsafe.
To avoid this error you could use the standard way a module is used in Vtiger by navigating to it like so: ......./index.php?module=Mytest&action=index. Vtiger will include your module and now there is no need for you to include CRMEntity and other data or utils related files. It should all be available this way but make sure you are using the global statement for $current_user, $current_module etc though.
Another way is to edit the following functions located in utils/CommonUtils.php:
heckFileAccessForInclusion() and checkFileAccess()
Remove or comment out the die() in these functions to fix it.
In Save.php file, just add a line.
$focus->column_fields['assigned_user_id'] = '';
before the
if($_REQUEST['assigntype'] == 'U') {
$focus->column_fields['assigned_user_id'] = $_REQUEST['assigned_user_id'];
} elseif($_REQUEST['assigntype'] == 'T') {
$focus->column_fields['assigned_user_id'] = $_REQUEST['assigned_group_id'];
}
To second what caspersky said:
Go to /include/database/PearDatabase.php and add
$adb->setDebug(true); right after $adb->connect();
I just wrote a module and received this error and it was because the record could not save because I left out:
$moduleInstance->setEntityIdentifier($fieldInstance);
Check out file permissions and file path it's trying to refer.
If you want to debug more set $adb->setDebug(true) in your index file and checkout for the errors.
A couple of things spring to mind:
Have you actually created the modules/CustomeModule directory and populated
it? (Using the template in vtlib/ModuleDir/5.4.0 and then editing the
filenames and class of CustomeModule.php)
Check the case of your module class definition, e.g. class CustomeModule
vs. class Customemodule
If you are using any version control or symlinks in the development
of your modules/Mytest code then this can trigger the "Sorry! Attempt
to access restricted file." messages.
In module setup script make sure you have added this lines.
$module->initTables();
$module->initWebservice();
Check that all language files exist.
The user module allows the admin user to configure a user's language even though the language file is not present on disk.
To quickly verify this is indeed the issue :-
- Edit the include/utils/CommonUtils.php and print the $realfilepath variable ,and comment out the die();
- In the database, "select distinct language from xxx_users";
You can fix this by downloading the required files.
As a quick fix (read:hack):-
- go to the include/language directory
- copy an existing language file as the required one. (may not always work - for example en_us to en_gb is great, but en_us to sp_es is not)
It seems you did not set write permission for Smarty folder
Probably a file is missing in your vtiger install.
To find out which one is mission you would need to edit the include/utils/CommonUtils.php file. Open it with a text editor, go around line 2755 and add the following
echo “REAL: $realfilepath, ROOT: $rootdirpath”;
Before die(Sorry....)
This would print on the screen which one is the missing file.
Sometimes this error is caused by an nonexistent module, what I mean here is that vtiger thinks you have a module but the files are not in there (might be caused by a bad migration to a new server).
Disable some modules and try again until you find which module is broken.
In my case the broken module was VGS.
I solved this on vtiger 7.3.. (maybe it works for other vesion)
I went to users permission on vtiger inside configuration settings and update tham all again with the same settings .. and got them to a more default settings .. them all users appeared back and I was able to create new users ..change password again.
I suggest logging out and maybe forcing refresh and waiting a little to make it work .