如何使用CodeIgniter Web框架创建日志文件? [英] How to create a log file with CodeIgniter Web Framework?

查看:55
本文介绍了如何使用CodeIgniter Web框架创建日志文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Web CodeIgniter 3.0框架有点陌生。

I am a bit new to the Web CodeIgniter 3.0 Framework.

我在Java Web编程方面以及在对所使用的数据库执行查询时有更多经验,将每个查询的log4j日志映射到数据库。

I have more experience in Java web programming, and when executing a query to the database used and that mapped the log4j log each query to the database.

数据库中是否有用于咨询和将来出现错误的插件或库? (对于使用CodeIgniter 3.0框架的PHP)。

Is there any plugin or library for consultation and future errors in the database? (for PHP using the CodeIgniter 3.0 Framework).

推荐答案

您可以使用函数 log_message

也可以设置您的application / config / config.php中的日志级别

Also you can set log level in your application/config/config.php

这是示例设置:

/*
|--------------------------------------------------------------------------
| Error Logging Threshold
|--------------------------------------------------------------------------
|       0                           = Disables logging, Error logging TURNED OFF
|       1                           = Error Messages (including PHP errors)
|       2                           = Debug Messages
|       3                           = Informational Messages
|       4                           = All Messages|
*/
$config['log_threshold']        = 2;
$config['log_path']             = '';
$config['log_date_format']      = 'Y-m-d H:i:s';

如果要对SQL查询使用自定义消息:

If you want to use custom message for sql queries:

if ($this->db->simple_query('YOUR QUERY'))
{
    echo "Success!";
}
else
{
    log_message('debug', 'sql query fail in... ', false);
}

这篇关于如何使用CodeIgniter Web框架创建日志文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆