2017-04-27 47 views
1

我使用此配置登录错误笨不会记录所有文件名错误日志中

$config['log_threshold'] = 1; 

问题是一些错误不包括像这样的文件名,而其他错误,包括文件名

ERROR - 2017-04-27 14:20:16 --> Query error: You have an error in your SQL syntax; check the 
manual that corresponds to your MySQL server version for the right syntax to use near 
'ORDER BY `id` DESC' at line 4 - Invalid query: SELECT COUNT(*) AS `numrows` FROM `orders` 
WHERE `id` > ORDER BY `id` DESC 

ERROR - 2017-04-27 14:20:16 --> Severity: Error --> Call to a member function num_rows() on 
boolean /home/username/public_html/system/database/DB_query_builder.php 1391 

为什么会发生这种情况,以及如何解决它。我发现这个答案Codeigniter error log not including file name但是找不到'MY_Log.php'

+0

您需要创建'application/core/MY_Log.php'文件。 – Shiva127

回答

0

我看到了答案:Codeigniter error log not including file name很清楚。按照这些步骤:

  1. 创建MY_Log.php文件(记得MY_Log.phpMY_log.php或别的东西)在application/core文件夹中。
  2. 复制下面的代码片段,并粘贴到文件:

    类MY_Log扩展CI_Log {

    public function write_log($level, $msg) 
    { 
        foreach (debug_backtrace() as $call) 
        { 
         // Somehow find the appropriate call here ... 
         if (! (/* condition to ignore error-handling calls */)) 
         { 
          break; 
         } 
    
         $msg = '['.$call['file'].'] '.$msg; 
         break; 
        } 
    
        return parent::write_log($level, $msg); 
    } 
    

    }

  3. 保存文件。完成!

+0

从行复制:'类MY_Log扩展CI_Log' – duyvu1311

+0

我没有但没有控制器文件名 –

+0

没有控制器文件名?你什么意思?你安装了哪个CI版本? – duyvu1311