在Laravel中,我可以使用log()
命令向日志文件添加注释(这有助于我调试(,类似于以下内容:
$var = 'this is a variable';
//some other code goes here
log::('Is $var a null? Here is the value '.$var);
然后我可以签入日志文件。
如何在OpenCart中执行此操作?
在OpenCart 2和3中,/system/library/log.php中有日志库
这个库几乎可以从任何地方访问(从任何模型和控制器(。你可以很容易地使用它,比如:
$var = 'this is a variable';
//some other code goes here
$this->log->write('Is $var a null? Here is the value '.$var);
您将在/system/storage/logs/error.Log中找到日志文件
其他方式
$var = 'this is a variable';
//some other code goes here
$log = new Log('LOG_NAME.log');
$log->write('Is $var a null? Here is the value '.$var);
您将在/system/storage/logs/中找到您的日志文件