当前位置:网站首页>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 high availability and persistence
- From "zero sum game" to "positive sum game", PAAS triggered the third wave of cloud computing
- Go语言自学系列 | golang switch语句
- Advanced Mathematics (Seventh Edition) Tongji University exercises 2-1 personal solutions
- Why can't strings be directly compared with equals; Why can't some integers be directly compared with the equal sign
- nifi从入门到实战(保姆级教程)——flow
- Mb10m-asemi rectifier bridge mb10m
- The difference between calling by value and simulating calling by reference
- Go language self-study series | if else if statement in golang
- Microservices - load balancing ribbon
猜你喜欢

Embedded development: seven reasons to avoid open source software
![[list to map] collectors Tomap syntax sharing (case practice)](/img/ac/e02deb1cb237806d357a88fb812852.jpg)
[list to map] collectors Tomap syntax sharing (case practice)

Distributed task scheduling XXL job

MongoDB 的安装和基本操作

"Remake Apple product UI with Android" (2) -- silky Appstore card transition animation

The mixlab editing team is recruiting teammates~~

From "zero sum game" to "positive sum game", PAAS triggered the third wave of cloud computing

Microservice - declarative interface call openfeign

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

About text selection in web pages and counting the length of selected text
随机推荐
Client does not support authentication protocol requested by server; consider upgrading MySQL client
From "zero sum game" to "positive sum game", PAAS triggered the third wave of cloud computing
Stm32f103c8t6 firmware library lighting
SDNU_ ACM_ ICPC_ 2022_ Winter_ Practice_ 4th [individual]
Calibre LVL
Use percent sign in CString
Uploads labs range (with source code analysis) (under update)
Hibernate的缓存机制/会话级缓存机制
uploads-labs靶场(附源码分析)(更新中)
ASEMI整流桥UMB10F参数,UMB10F规格,UMB10F封装
Jmeter线程组功能介绍
几种常见IO模型的原理
Problems of CString in multithreading
[system safety] 43 PowerShell malicious code detection series (5) automatic extraction of ten thousand words from abstract syntax tree
深度学习之三维重建
请做好3年内随时失业的准备?
Using optimistic lock and pessimistic lock in MySQL to realize distributed lock
切入点表达式
Colab works with Google cloud disk
How to initialize views when loading through storyboards- How is view initialized when loaded via a storyboard?