ThinkPHP logs

Last Updated: Sep 30, 2017

ThinkPHP is a Web application development framework based on the PHP language.

ThinkPHP sample log

The following logging method is used in ThinkPHP:

  1. <?php
  2. Think\Log::record('D model class not found for method instantiation' );
  3. ?>

Sample log

  1. [ 2016-05-11T21:03:05+08:00 ] 30.9.181.163 /index.php
  2. INFO: [ app_init ] --START--
  3. INFO: Run Behavior\BuildLiteBehavior [ RunTime:0.000014s ]
  4. INFO: [ app_init ] --END-- [ RunTime:0.000091s ]
  5. INFO: [ app_begin ] --START--
  6. INFO: Run Behavior\ReadHtmlCacheBehavior [ RunTime:0.000038s ]
  7. INFO: [ app_begin ] --END-- [ RunTime:0.000076s ]
  8. INFO: [ view_parse ] --START--
  9. INFO: Run Behavior\ParseTemplateBehavior [ RunTime:0.000068s ]
  10. INFO: [ view_parse ] --END-- [ RunTime:0.000104s ]
  11. INFO: [ view_filter ] --START--
  12. INFO: Run Behavior\WriteHtmlCacheBehavior [ RunTime:0.000032s ]
  13. INFO: [ view_filter ] --END-- [ RunTime:0.000062s ]
  14. INFO: [ app_end ] --START--
  15. INFO: Run Behavior\ShowPageTraceBehavior [ RunTime:0.000032s ]
  16. INFO: [ app_end ] --END-- [ RunTime:0.000070s ]
  17. ERR: D model class not found for method instantiation

Collect ThinkPHP logs using Logtail

For more information about the standard process, see Quick start and Apache Log. Choose the corresponding configuration based on your network deployment and actual situation.

The automatically generated results are for reference only. You need to manually edit the generated regular expression to fit all the logs that may be selected by Logtail.

ThinkPHP logs are multiline logs in varying modes. The following fields can be extracted from these logs: time, IP address of the visitor, accessed URL, and printed message. Because the message mode is not fixed, the message is packaged into a field containing multiple lines of information.

Logtail collects configuration parameters of ThinkPHP log

In Log Service, select multiline mode and enter the following regular expression at the beginning of the line.

  1. \[\s\d+-\d+-\w+:\d+:\d+\+\d+:\d+\s.*

Regular expression:

  1. \[\s(\d+-\d+-\w+:\d+:\d+)[^:]+:\d+\s]\s+(\S+)\s(\S+)\s+(.*)

Time expression:

  1. %Y-%m-%dT%H:%M:%S
Thank you! We've received your feedback.