CI中的LOG和错误处理小结

在CI中,对于错误处理和LOG的处理方法,下面小结下:
1 默认在index.php 中,error的级别是ALL,把所有信息都设置出来的
error_reporting(E_ALL);
可以把其改成E_ERROR级别

2 设置LOG,LOG在application/config下设置
$config['log_threshold'] = 0;

/*
|--------------------------------------------------------------------------
| Error Logging Directory Path
|--------------------------------------------------------------------------
|
| Leave this BLANK unless you would like to set something other than the default
| system/logs/ folder. Use a full server path with trailing slash.
|
*/
$config['log_path'] = '';

0-关闭
1 – ERROR
记录所有的错误信息了,连HTML的404错误,和用户端定义的错误
2-DEBUG
3-INO:这个级别输出ERROR和DEBUG级别的,都一起了
4 ALL-MESSAGE:输出所有信息了

$config['log_path'] = ”
如果您不想使用默认的错误日志记录目录配置(system/logs/),可以设置完整的服务器目录。

$config['log_date_format'] = ‘Y-m-d H:i:s’
codeigniter 错误日志时间格式


log_message('级别', '消息')

这个函数可以让你将消息写入记录文件中。你必须在第一个参数中选择三个“级别“中的任何一个, 指明它是那一类消息(调试 debug, 错误 error, 信息info)。 第二个参数是消息本身。 例如:

if ($some_var == "")
{
log_message('error', 'Some variable did not contain a value.');
}
else
{
log_message('debug', 'Some variable was correctly set');
}

log_message('info', 'The purpose of some variable is to provide some value.');


而默认的错误定制页在:application/errors/error_general.php和
application/errors/error_404.php 中
可以利用show_error和show_404() 去显示错误信息
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值