当前位置:网站首页>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.');
边栏推荐
- Redis在Windows以及Linux系统下的安装
- Slam learning notes - build a complete gazebo multi machine simulation slam from scratch (4)
- [200 opencv routines] 217 Mouse interaction to obtain polygon area (ROI)
- nifi从入门到实战(保姆级教程)——flow
- 工资3000,靠“视频剪辑”月入40000:会赚钱的人,从不靠拼命!
- Principles of several common IO models
- WinDbg analysis dump file
- Three dimensional reconstruction of deep learning
- 一些事情的反思
- 大csv拆分和合并
猜你喜欢
nifi从入门到实战(保姆级教程)——flow
How to use AAB to APK and APK to AAB of Google play apps on the shelves
Microservices - load balancing ribbon
From "zero sum game" to "positive sum game", PAAS triggered the third wave of cloud computing
Asemi rectifier bridge umb10f parameters, umb10f specifications, umb10f package
Microservice - fuse hystrix
ASEMI整流桥UMB10F参数,UMB10F规格,UMB10F封装
How can technology managers quickly improve leadership?
About text selection in web pages and counting the length of selected text
How idea starts run dashboard
随机推荐
高等数学(第七版)同济大学 习题2-1 个人解答
Record a jar package conflict resolution process
嵌入式开发:避免开源软件的7个理由
[list to map] collectors Tomap syntax sharing (case practice)
Go language self-study series | golang switch statement
Stm32f103c8t6 firmware library lighting
工资3000,靠“视频剪辑”月入40000:会赚钱的人,从不靠拼命!
[combinatorics] combinatorial identities (sum of variable terms 3 combinatorial identities | sum of variable terms 4 combinatorial identities | binomial theorem + derivation to prove combinatorial ide
Intelij idea efficient skills (III)
Redis高可用与持久化
远程文件包含实操
Automatic generation of client code from flask server code -- Introduction to flask native stubs Library
Persisting in output requires continuous learning
Go语言自学系列 | golang中的if else语句
How to use AAB to APK and APK to AAB of Google play apps on the shelves
Go语言自学系列 | golang switch语句
“用Android复刻Apple产品UI”(3)—优雅的数据统计图表
Shell script import and export data
Salary 3000, monthly income 40000 by "video editing": people who can make money never rely on hard work!
[proteus simulation] 8 × 8LED dot matrix screen imitates elevator digital scrolling display