PHP code example of hulang / think-log-driver

1. Go to this page and download the library: Download hulang/think-log-driver 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/ */

    

hulang / think-log-driver example snippets


// 日志记录方式
// 日志通道列表

    'channels'     => [
        'file'=>[],
        'database' => [
            // 日志记录方式
            'type'           => 'Database',
            // 大于0.05秒的sql将被记录
            'slow_sql_time'  => 0.5,
            // 记录日志的数据库配置,即在database.php中的driver
            // 如果设置该值为'default',则使用系统数据库的实例
            'db_connect'     => 'default', //mongodb 
            // 记录慢日志查询的数据表名
            'db_table'       => 'log_sql',
            // 忽略的操作,在以下数据中的操作不会被记录
            'action_filters' => [
                // 'index/Index/lst'
            ],
            // 日志保存目录
            'path'           => '',
            // 单文件日志写入
            'single'         => false,
            // 独立日志级别
            'apart_level'    => [],
            // 最大日志文件数量
            'max_files'      => 0,
            // 使用JSON格式记录
            'json'           => false,
            // 日志处理
            'processor'      => null,
            // 关闭通道日志写入
            'close'          => false,
            // 日志输出格式化
            'format'         => '[%s][%s] %s',
            // 是否实时写入
            'realtime_write' => false,
        ],
],