Home  >  Article  >  Backend Development  >  How to view components in Hyperf logs

How to view components in Hyperf logs

coldplay.xixi
coldplay.xixiforward
2020-08-31 17:29:053373browse

How to view components in Hyperf logs

【Related learning recommendations: php graphic tutorial

Recently, I need to use the function of using routing to view How to view components in Hyperf logs logs online in Hyperf. I haven't found one that is easy to use, so I simply wrote one myself, which supports viewing and simple content search.

1. Interface

First, the rendering:

How to view components in Hyperf logs

2. Use

  • 1. Install components

composer require sett/hyperf-log-viewer

  • 2 .Publish configuration How to view components in Hyperf logs

php bin/hyperf.php vendor:publish sett/hyperf-log-viewer

  • 3.Register route

Router::get('/logs', 'Sett\LogViewer\Controller\LogViewController@index');

  • 4. Install the view component

composer require hyperf/view

  • 5. Install the template engine

composer require sy- records/think-template

  • 6. Configure view
return [
        'engine' => ThinkEngine::class,
        'mode'   => Mode::TASK,
        'config' => [
            // 若下列文件夹不存在请自行创建
            'view_path'  => BASE_PATH . '/storage/view/',
            'cache_path' => BASE_PATH . '/runtime/view/',
        ],];
  • 7. Configure component parameters

In the config\autoload\logViewer.php How to view components in Hyperf logs, add your own log How to view components in Hyperf logs directory

return [ 
   "path" => BASE_PATH . "/runtime/logs/", 
   "pattern" => "*.log", 
   "size" => 10 
   ];

3. Description

  • The log time format is only Supports the year, month, day, hour, minute and second format, otherwise you may not be able to see the record

Related learning recommendations:php programming(video)

The above is the detailed content of How to view components in Hyperf logs. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:learnku.com. If there is any infringement, please contact admin@php.cn delete