当前位置:网站首页>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.');
边栏推荐
- Using optimistic lock and pessimistic lock in MySQL to realize distributed lock
- 高等数学(第七版)同济大学 习题2-1 个人解答
- SDNU_ ACM_ ICPC_ 2022_ Winter_ Practice_ 4th [individual]
- Go语言自学系列 | golang switch语句
- Distributed task scheduling XXL job
- Colab works with Google cloud disk
- Low level version of drawing interface (explain each step in detail)
- Why can't strings be directly compared with equals; Why can't some integers be directly compared with the equal sign
- 深度学习之三维重建
- Mixlab编辑团队招募队友啦~~
猜你喜欢

Slam learning notes - build a complete gazebo multi machine simulation slam from scratch (4)

Download and install common programs using AUR

“用Android复刻Apple产品UI”(2)——丝滑的AppStore卡片转场动画

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

Salary 3000, monthly income 40000 by "video editing": people who can make money never rely on hard work!

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

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

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

Create gradle project

“用Android复刻Apple产品UI”(3)—优雅的数据统计图表
随机推荐
Three dimensional reconstruction of deep learning
Remote file contains actual operation
Brush questions -- sword finger offer
近视:摘镜or配镜?这些问题必须先了解清楚
CString getbuffer and releasebuffer instructions
关于网页中的文本选择以及统计选中文本长度
Create gradle project
深度学习之三维重建
首发!!lancet饿了么官方文档
Redis在Windows以及Linux系统下的安装
June to - -------
Automatic generation of client code from flask server code -- Introduction to flask native stubs Library
Hibernate的缓存机制/会话级缓存机制
Get the executable path through the process PID (queryfullprocessimagename)
App mobile terminal test [4] APK operation
Microservice - declarative interface call openfeign
Slam learning notes - build a complete gazebo multi machine simulation slam from scratch (I)
The wonderful use of do{}while()
How to initialize views when loading through storyboards- How is view initialized when loaded via a storyboard?
Redis高可用与持久化