Wednesday, July 27, 2011

SugarCRM - Adding Logging into sugarcrm.log

If you would like to use the SugarCRM log in order to help you debug an issue you may be having with some code, it is fairly easy to do.   All you have to do is add the following line of code:

$GLOBALS['log']->debug("Debug Message");

In order to view this message, you must make sure that you have set this message up correctly.  First, notice in the call above, I have the debug piece in the call.  This refers to the actual level of the call.  In order to view this message in the log, you will need to make sure that the setting in the admin is set to be at this setting or above to view these messages.  You may choose to change the level of the message to any of the levels listed below.  Just be careful with case.

If you go to Admin->System Settings->Log Level, there is a drop-down box of the levels that you can be at.  They are listed in order of precedence.  If you have a level at a higher level, it will display messages for those of the lower level.  Here is the list:

Debug
Info
Warn
Deprecated
Error
Fatal
Security
Off


So, if you have Error chosen, it will show messages marked as Error or Security.


Where I have "Debug Message", you may put any message that you would like displayed in your log.

In order to view the log, you can view it from the link in the admin right below the drop-down mentioned above or you can use an editor.

No comments:

Post a Comment