当前位置:网站首页>PHP CI(CodeIgniter)log级别设置
PHP CI(CodeIgniter)log级别设置
2022-07-03 16:08:00 【星哥玩云】
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.');
边栏推荐
- Microservice - fuse hystrix
- 远程办公之大家一同实现合作编辑资料和开发文档 | 社区征文
- Vs2017 is driven by IP debugging (dual machine debugging)
- Persisting in output requires continuous learning
- 利用MySQL中的乐观锁和悲观锁实现分布式锁
- 切入点表达式
- Redis high availability and persistence
- From "zero sum game" to "positive sum game", PAAS triggered the third wave of cloud computing
- Please be prepared to lose your job at any time within 3 years?
- Create gradle project
猜你喜欢

Microservice - Nacos registration center and configuration center

【Proteus仿真】74HC595+74LS154驱动显示16X16点阵

请做好3年内随时失业的准备?

The mixlab editing team is recruiting teammates~~

Automatic generation of client code from flask server code -- Introduction to flask native stubs Library

Brush questions -- sword finger offer

Low level version of drawing interface (explain each step in detail)

"Remake Apple product UI with Android" (3) - elegant statistical chart

工资3000,靠“视频剪辑”月入40000:会赚钱的人,从不靠拼命!
![[proteus simulation] 74hc595+74ls154 drive display 16x16 dot matrix](/img/d6/3c21c25f1c750f17aeb871124e80f4.png)
[proteus simulation] 74hc595+74ls154 drive display 16x16 dot matrix
随机推荐
Download and install common programs using AUR
【Proteus仿真】8×8LED点阵屏仿电梯数字滚动显示
Vs2017 is driven by IP debugging (dual machine debugging)
Unity项目优化案例一
App mobile terminal test [5] file writing and reading
0214-27100 a day with little fluctuation
远程文件包含实操
From the 18th line to the first line, the new story of the network security industry
[combinatorics] combinatorial identity (sum of combinatorial identity products 1 | sum of products 1 proof | sum of combinatorial identity products 2 | sum of products 2 proof)
[redis foundation] understand redis master-slave architecture, sentinel mode and cluster together (Demo detailed explanation)
Mongodb installation and basic operation
[proteus simulation] 74hc595+74ls154 drive display 16x16 dot matrix
From "zero sum game" to "positive sum game", PAAS triggered the third wave of cloud computing
《天天数学》连载56:二月二十五日
SDNU_ ACM_ ICPC_ 2022_ Winter_ Practice_ 4th [individual]
Win32 create window and button (lightweight)
pyinstaller不是内部或外部命令,也不是可运行的程序 或批处理文件
“用Android复刻Apple产品UI”(3)—优雅的数据统计图表
The accept attribute of the El upload upload component restricts the file type (detailed explanation of the case)
Is it safe to open an account with flush?