Php ci (CodeIgniter) log-level settings

Source: Internet
Author: User
Tags codeigniter

Php ci (CodeIgniter) log-level settings

1. The Ci error level is generally set in index. php. You can set ENVIRONMENT. Generally, select the development mode during development. After the official release, select the production mode.

The Code is as follows:

/*
*---------------------------------------------------------------
* APPLICATION ENVIRONMENT
*---------------------------------------------------------------
*
* You can load different tolerations 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 ('enable '))
{
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 error logs are stored in application/logs/log-[time] by default. in php, the log level, path, and time format are stored in application/config. PHP File Settings, the relevant code is as follows:

/*
| --------------------------------------------------------------------------
| Error Logging Threshold
| --------------------------------------------------------------------------
|
| If you have enabled error logging, you can set an error threshold
| Determine what gets logged. Threshold options are:
| You can enable error logging by setting a threshold over zero.
| 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 wowould 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. When writing your own code to record logs, you can call the global function log_message ('level', 'message'). The parameter levels are (debug, error, information info), the content can be customized.

Log_message ('error', 'error message .');
Log_message ('debug', 'debug message .');
Log_message ('info', 'info message .');

Install LNMP in CentOS 6.3 (PHP 5.4, MyySQL5.6)

Nginx startup failure occurs during LNMP deployment.

Ubuntu install Nginx php5-fpm MySQL (LNMP environment setup)

Detailed php hd scanning PDF + CD source code + full set of teaching videos

PHP details: click here
PHP: click here

This article permanently updates the link address:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.