当前位置:网站首页>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.');
边栏推荐
- Effect of ARP package on FTP dump under vxworks-6.6 system
- pycharm错Error updating package list: connect timed out
- Slam learning notes - build a complete gazebo multi machine simulation slam from scratch (II)
- 分布式事务(Seata) 四大模式详解
- Famous blackmail software stops operation and releases decryption keys. Most hospital IOT devices have security vulnerabilities | global network security hotspot on February 14
- 0214-27100 a day with little fluctuation
- nifi从入门到实战(保姆级教程)——flow
- Vs2017 is driven by IP debugging (dual machine debugging)
- 六月 致 -.-- -..- -
- Driver and application communication
猜你喜欢

半监督学习

App移动端测试【3】ADB命令

Nifi from introduction to practice (nanny level tutorial) - flow

The accept attribute of the El upload upload component restricts the file type (detailed explanation of the case)

Mb10m-asemi rectifier bridge mb10m

Mongodb installation and basic operation

Rk3399 platform development series explanation (WiFi) 5.54. What is WiFi wireless LAN

【Proteus仿真】8×8LED点阵屏仿电梯数字滚动显示

Distributed task scheduling XXL job

App移动端测试【4】apk的操纵
随机推荐
“用Android复刻Apple产品UI”(2)——丝滑的AppStore卡片转场动画
Rk3399 platform development series explanation (WiFi) 5.54. What is WiFi wireless LAN
Intelij idea efficient skills (III)
Introduction series of software reverse cracking (1) - common configurations and function windows of xdbg32/64
Go language self-study series | if else statement in golang
pyinstaller不是内部或外部命令,也不是可运行的程序 或批处理文件
Colab works with Google cloud disk
Page dynamics [2]keyframes
关于网页中的文本选择以及统计选中文本长度
How to initialize views when loading through storyboards- How is view initialized when loaded via a storyboard?
How idea starts run dashboard
Redis高可用与持久化
Salary 3000, monthly income 40000 by "video editing": people who can make money never rely on hard work!
Mixlab编辑团队招募队友啦~~
Slam learning notes - build a complete gazebo multi machine simulation slam from scratch (III)
相同切入点的抽取
[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)
【OpenCV 例程200篇】217. 鼠标交互获取多边形区域(ROI)
坚持输出需要不断学习
First!! Is lancet hungry? Official documents