Skip to content

Instantly share code, notes, and snippets.

@cmourizard
Created October 1, 2014 19:06
Show Gist options
  • Save cmourizard/3e3762bbf709ef4b05e0 to your computer and use it in GitHub Desktop.
Save cmourizard/3e3762bbf709ef4b05e0 to your computer and use it in GitHub Desktop.
Custom SugarCRM logger to log messages in your own log file
<?php
require_once 'include/SugarLogger/SugarLogger.php';
class custom_Company_Helper_Logger extends SugarLogger
{
protected $logfile = 'company_logger';
protected $ext = '.log';
protected $dateFormat = '%c';
protected $logSize = '10MB';
protected $maxLogs = 10;
protected $filesuffix = "";
protected $date_suffix = "";
protected $log_dir = './';
public function __construct()
{
$this->_doInitialization();
}
}
<?php
require_once 'custom/Company/Helper/Logger.php';
$myLogger = new custom_Company_Helper_Logger();
$casLog->log('fatal', 'My comment logged with fatal level');
@thehappycoder
Copy link

@thehappycoder
Copy link

But thanks for the snippet! It's very useful!

@palanisankararun26
Copy link

palanisankararun26 commented Dec 3, 2018

Can you explain the userLogger.php and how it writes the result into company_logger.log?

@palanisankararun26
Copy link

$casLog->log('fatal', 'My comment logged with fatal level');
shuld be $myLogger->log('fatal', 'My comment logged with fatal level');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment