PHP code example of shallowman / laralog

1. Go to this page and download the library: Download shallowman/laralog library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

shallowman / laralog example snippets


    $middleware = [
        ...
        \Shallowman\Laralog\Http\Middleware\CaptureRequestLifecycle::class,
    ];
    

    'daily' => [
         // Monolog 提供的 driver,保留不变
        'driver' => 'daily',
        // channel 名称,要与数组键名保持一致
        'name'   => 'daily',
        // 日志存储路径,及日志文件命名
        // 增加 Hostname 作为日志存储文件名后缀
        'path'   => sprintf(env('DAILY_LARALOG_STORAGE_PATH', storage_path('logs/laralog-%s.log')), gethostname()),
        // 指定使用的日志格式化组件类
        'tap'    => [
            \Shallowman\Laralog\Formatter\LaralogFormatter::class,
            \Shallowman\Laralog\Processor\LaralogProcessor::class,
        ],
        'level'  => 'info',
        // 日志文件保留天数
        'days'   => 7,
        // 在写日志文件前获得锁,避免并发写入造成的争抢,写错行
        'locking'=> true,
    ],
    

    return [
        'except' => [
            'fields'=>[
                'password',
                'password_information',
                'password_confirm',
                'something_to_except',
            ],            
        ],
    ];
    

        return [
            'except' => [
                'uri'=>[
                    '/welcome',
                    '/uri/to/filter'
                ],            
            ],
        ];
     

    'log_clipped_length' => env('LARALOG_CLIPPED_LENGTH', CaptureRequestLifecycle::POSITIVE_INFINITY),
  

  
  
  return [
      'except' => [
          // The fields filled in the blow array will be excluded to print in the log which in the http request body carried items
          // perfect match
          'fields' => [
              'password',
              'password_information',
              'password_confirm',
          ],
          // The uris filled in the blow array will be excluded to print http response body
          // Using full fuzzy matching
          'uris' => [
              '/welcome',
          ],
      ],
  
      'log_clipped_length' => env('LARALOG_CLIPPED_LENGTH', \Shallowman\Laralog\Http\Middleware\CaptureRequestLifecycle::POSITIVE_INFINITY),
  ];
  

    Log::info('log message', $context);
    

    Log::channel('channel')->info('message', $context);
    
sh
        php artisan vendor:publish --provider="Shallowman\Laralog\ServiceProvider"