thinkphp Debug mode and Logging overview, thinkphp logging _php Tutorial

Source: Internet
Author: User

thinkphp Debug mode and Logging overview, thinkphp logging


This article is described as the use of thinkphp debug mode and logging, which plays a very important role in the development of thinkphp project, it is necessary to understand and grasp. Here's how:

1, can be set in config.php, the default is off state.

The opening method is as follows:

' App_debug '  = True

Open the \thinkphp\common\debug.php file to see the default settings for debug as follows:

Return Array (  ' Log_record ' =>true,//Logging  ' log_record_level '    = =  Array (' Emerg ', ' ALERT ', ' Crit ', ' ERR ', ' WARN ', ' notic ', ' INFO ', ' DEBUG ', ' SQL '),//allow logging of log levels  ' Db_fields_cache ' + false,//database field cache  ' Show_run_time ' =>true,     //Run time display  ' Show_adv_time ' =>true,     //show verbose run time  ' show_db_times ' = True,     //Display database query and write times  ' Show_cache_times ' =>true,    //Display cache operation Count  ' Show_use_mem ' =>true,      //Display memory overhead  ' Show_page_trace ' =>true,    //Display page trace information assigned by trace file definition and action action  ' app_file_case ' = >  True,//whether check file capitalization is valid for Windows platform);

Note: The Db_fields_cache database field cache is closed by default, if it is turned on, the file cache is generated under the Runtime\data folder, and after the table has been modified, such as the newly added field, this cache cannot record your operation, we need to delete it manually. Changes to the table will not succeed.

After the ' App_debug ' is true, the access page will appear as a DEBUG prompt:

If you want to display only a subset of the information, such as run time, memory overhead, etc.,

You can make the appropriate settings in config.php, such as:

' App_debug ' +  true,//debug mode switch ' Show_run_time ' + true,//Run time display ' show_adv_time ' = true,//show verbose run time ' show _db_times ' + true,//Display database operation Count ' Show_cache_times ' =>true,//Display cache operation count ' show_use_mem ' = true,//display memory overhead

Tip information such as:

2, the page trace information customization: \thinkphp\tpl\pagetrace.tpl.php

Custom method One: Add a trace.php file to the config.php's sibling directory with the following code:

<?php return array{  ' current SERVER information ' =>$_server[' REMOTE_ADDR '],};? >

Custom method Two: Add in the action method:

$this->trace (' Debug Test ', ' 5211314 ');

3, Output Debugging method:

Halt (' aaaaaaa ');//output AAAAAA and interrupt program execution

4. Model debugging: Displaying SQL statements

$User =new Model (' User '); $User->find (1); echo $User->getlastsql ();//output the last SQL statement executed

5. Log record \thinkphp\lib\think\core\log.class.php

Set in config.php

' Log_record ' =>true,//turns on logging ' Log_record_level ' =>array (' Emerg ', ' ALERT ', ' ERROR '),

I hope the method described in this article is helpful to everyone.


thinkphp where the log record file is found

Log record \thinkphp\lib\think\core\log.class.php

1, can be set in config.php, the default is off state. ' App_debug ' = True

Open the \thinkphp\common\debug.php file to see the default settings for debug as follows:

Return Array (

' Log_record ' =>true,//logging

' Log_record_level ' = = Array (' Emerg ', ' ALERT ', ' crit ', ' ERR ', ' WARN ', ' notic ', ' INFO ', ' DEBUG ', ' SQL '),//allow logging of log levels
' Db_fields_cache ' = false,//database field cache

' Show_run_time ' =>true,//Run time display
' Show_adv_time ' =>true,//show verbose run time
' Show_db_times ' =>true,//Display database query and write times
' Show_cache_times ' =>true,//display the number of cache operations
' Show_use_mem ' =>true,//display memory overhead
' Show_page_trace ' =>true,//Display page trace information is assigned by the trace file definition and action action
' App_file_case ' = true,//check if file capitalization is valid for Windows platform
);

Note: The Db_fields_cache database field cache is closed by default, if it is turned on, the file cache is generated under the Runtime\data folder, and after the table has been modified, such as the newly added field, this cache cannot record your operation, we need to delete it manually. Changes to the table will not succeed.

After the ' App_debug ' is true, the access page will appear as a DEBUG prompt:

If you want to display only a subset of the information, such as run time, memory overhead, etc.,

You can make the appropriate settings in config.php, such as:

' App_debug ' = = true,//debug mode switch
' Show_run_time ' + true,//Run time display
' Show_adv_time ' = true,//show verbose run time
' show_db_times ' = = true,//display number ... Remaining full text >>
Zhang Haibo[authoritative experts]

thinkphp calling templates and debugging modes

Let me tell you the answer!
This is fine, you build a IndexAction.class.php file in the Admin/lib/action,
Display ();
}
}
Then build an index folder in the ADMIN/TPL, and build a index.html file in this folder.

http://www.bkjia.com/PHPjc/868234.html www.bkjia.com true http://www.bkjia.com/PHPjc/868234.html techarticle thinkphp Debug mode and Logging overview, thinkphp logging is described in this article as thinkphp debug mode and logging usage, which is in the process of thinkphp project development ...

  • Related Article

    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.