2017-04-27 53 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