共计 3025 个字符,预计需要花费 8 分钟才能阅读完成。
1、Ci 的报错级别设置一般在 index.php 中,可以设置 ENVIRONMENT。一般来讲,开发的时候选择 development 模式,正式发布之后,选择 production 模式。
代码如下:
/*
*—————————————————————
* APPLICATION ENVIRONMENT
*—————————————————————
*
* You can load different configurations depending on your
* current environment. Setting the environment also influences
* things like logging and error reporting.
*
* This can be set to anything, but default usage is:
*
* development
* testing
* production
*
* NOTE: If you change these, also change the error_reporting() code below
*
*/
define(‘ENVIRONMENT’, ‘development’);
/*
*—————————————————————
* ERROR REPORTING
*—————————————————————
*
* Different environments will require different levels of error reporting.
* By default development will show errors but testing and live will hide them.
*/
if (defined(‘ENVIRONMENT’))
{
switch (ENVIRONMENT)
{
case ‘development’:
error_reporting(E_ALL);
break;
case ‘testing’:
case ‘production’:
error_reporting(0);
break;
default:
exit(‘The application environment is not set correctly.’);
}
}
2、CI 的错误日志默认存放在 application/logs/log-[time].php 中,日志的级别、路径、时间格式等,在 application/config/config.php 文件中设置,相关代码如下:
/*
|————————————————————————–
| Error Logging Threshold
|————————————————————————–
|
| If you have enabled error logging, you can set an error threshold to
| determine what gets logged. Threshold options are:
| You can enable error logging by setting a threshold over zero. The
| threshold determines what gets logged. Threshold options are:
|
| 0 = Disables logging, Error logging TURNED OFF
| 1 = Error Messages (including PHP errors)
| 2 = Debug Messages
| 3 = Informational Messages
| 4 = All Messages
|
| For a live site you’ll usually only enable Errors (1) to be logged otherwise
| your log files will fill up very fast.
|
*/
$config[‘log_threshold’] = 0;
/*
|————————————————————————–
| Error Logging Directory Path
|————————————————————————–
|
| Leave this BLANK unless you would like to set something other than the default
| application/logs/ folder. Use a full server path with trailing slash.
|
*/
$config[‘log_path’] = ”;
/*
|————————————————————————–
| Date Format for Logs
|————————————————————————–
|
| Each item that is logged has an associated date. You can use PHP date
| codes to set your own date formatting
|
*/
$config[‘log_date_format’] = ‘Y-m-d H:i:s’;
3、在自己写代码需要记录日志时,可以调用全局函数 log_message(‘ 级别 ’,’ 消息 ’),级别的参数为 (调试 debug, 错误 error, 信息 info),内容自己定义即可。
log_message(‘error’, ‘error message.’);
log_message(‘debug’, ‘debug message.’);
log_message(‘info’, ‘info message.’);
CentOS 6.3 安装 LNMP (PHP 5.4,MyySQL5.6) http://www.linuxidc.com/Linux/2013-04/82069.htm
在部署 LNMP 的时候遇到 Nginx 启动失败的 2 个问题 http://www.linuxidc.com/Linux/2013-03/81120.htm
Ubuntu 安装 Nginx php5-fpm MySQL(LNMP 环境搭建) http://www.linuxidc.com/Linux/2012-10/72458.htm
《细说 PHP》高清扫描 PDF+ 光盘源码 + 全套教学视频 http://www.linuxidc.com/Linux/2014-03/97536.htm
PHP 的详细介绍 :请点这里
PHP 的下载地址 :请点这里