【问题标题】:How to disable codeigniter debug mode如何禁用 codeigniter 调试模式
【发布时间】:2015-12-18 13:11:47
【问题描述】:

我正在使用以下配置的 codeigniter 记录器:

$config['log_threshold'] = 4;

这些是 application/config/config.php 中使用的 5 个阈值

 0 = Disables logging, Error logging TURNED OFF
   1 = Error Messages (including PHP errors)
   2 = Debug Messages
   3 = Informational Messages
   4 = All Messages

我只想使用阈值 1 和 3。 如果我在阈值中使用 4,我可以打印带有许多调试消息的日志消息。这些调试消息将填满我的服务器空间。所以我想禁用这个调试模式。

我使用的是 codeigniter 2.2.0 版

这是我的日志文件:

  DEBUG - 2015-09-14 17:17:22 --> Config Class Initialized
  DEBUG - 2015-09-14 17:17:22 --> Hooks Class Initialized
  DEBUG - 2015-09-14 17:17:22 --> Utf8 Class Initialized
  DEBUG - 2015-09-14 17:17:22 --> UTF-8 Support Enabled
  DEBUG - 2015-09-14 17:17:22 --> URI Class Initialized
  DEBUG - 2015-09-14 17:17:22 --> Router Class Initialized
  DEBUG - 2015-09-14 17:17:22 --> Output Class Initialized
  DEBUG - 2015-09-14 17:17:22 --> Security Class Initialized
  DEBUG - 2015-09-14 17:17:22 --> Input Class Initialized
  DEBUG - 2015-09-14 17:17:22 --> Global POST and COOKIE data sanitized

【问题讨论】:

    标签: codeigniter


    【解决方案1】:

    在 CI3 中,您可以传递要写入的案例/键数组。 在 CI2 中,您需要在 BASEPATH . 'Log.php' 文件的 ln 34 上的数组 $_levels 中切换键的位置,或者如果您不想弄乱系统文件(这应该是一种好的行为),您可以扩展图书馆:

    class MY_Log extends CI_Log
    {
        protected $_levels  = array('ERROR' => '1', 'INFO' => '2',  'DEBUG' => '3', 'ALL' => '4');
    /**
     * Constructor
     */
        public function __construct()
        {
            parent::__construct();
        }
    }
    

    我相信这种方式也应该有效。

    【讨论】:

    • 我在我现有的 system/libraries/Log.php 中切换键的位置并使用 $config['log_threshold'] = array(3, 1);它没有解决我的问题。
    • 如果你已经像我展示的例子那样设置了数组,试试$config['log_threshold'] = 2;
    • 谢谢。这个对我有用。我看到以下错误消息:ERROR - 2015-09-23 17:52:11 --> Severity: 8192 --> mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead如果我将我的数据库驱动程序名称更改为 mysqli,所有 mysql 功能都停止工作,请建议我如何从记录器中删除此错误消息
    • 你的意思是:你只想要日志中显示的信息,而不是错误?
    • 实际上我需要错误和信息消息,但我想从记录器中删除此消息:错误 - 2015-09-23 17:52:11 --> 严重性:8192 --> mysql_pconnect() : mysql 扩展已弃用,将来将被删除:改用 mysqli 或 PDO
    猜你喜欢
    • 2016-09-25
    • 1970-01-01
    • 2021-09-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-30
    相关资源
    最近更新 更多