Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log::getLog()获取不到日志内容 #3006

Closed
490626721 opened this issue May 12, 2024 · 1 comment
Closed

Log::getLog()获取不到日志内容 #3006

490626721 opened this issue May 12, 2024 · 1 comment

Comments

@490626721
Copy link

版本:

 "php": ">=8.0.0",
  "topthink/framework": "^8.0",

日志配置文件:

<?php

// +----------------------------------------------------------------------
// | 日志设置
// +----------------------------------------------------------------------
return [
    // 默认日志记录通道
    'default'      => 'file',
    // 日志记录级别
    'level'        => ['wechat', 'sys', 'sql'],
    // 日志类型记录的通道 ['error'=>'email',...]
    'type_channel' => [
        'wechat'    =>    'wechat',
        'sys'    =>    'sys',
        'sql'    =>    'sql',
    ],
    // 关闭全局日志写入
    'close'        => false,
    // 日志通道列表
    'channels'     => [
        'file' => [
            // 日志记录方式
            'type'        => 'File',
            // 日志保存目录
            'path'        => public_path() . "Logs/main",
            // 单文件日志写入
            'single'      => true,
            // 独立日志级别
            'apart_level' => [],
            // 最大日志文件数量
            'max_files'      => 50,
            // 单个日志文件大小
            'file_size' => 1024*1024*10,
            // 使用JSON格式记录
            'json'           => true,
        ],
        // 其它日志通道配置
        // 微信日志
        'wechat' => [
            // 日志记录方式
            'type'           => 'File',
            // 日志保存目录
            'path'           => public_path() . "Logs/wechat",
            // 单文件日志写入
            'single'         => true,
            // 独立日志级别
            'apart_level'    => [],
            // 最大日志文件数量
            'max_files'      => 50,
            // 单个日志文件大小
            'file_size' => 1024*1024*10,
            // 使用JSON格式记录
            'json'           => true,
            // 日志处理
            'processor'      => null,
            // 关闭通道日志写入
            'close'          => false,
            // 时间格式化
            'time_format'   =>    'Y-m-d H:i:s',
            // 日志输出格式化
            'format'         => '[%s][%s] %s',
            // 是否实时写入
            'realtime_write' => true,
        ],
        // 系统日志
        'sys' => [
            // 日志记录方式
            'type'           => 'File',
            // 日志保存目录
            'path'           => public_path() . "Logs/sys",
            // 单文件日志写入
            'single'         => true,
            // 独立日志级别
            'apart_level'    => [],
            // 最大日志文件数量
            'max_files'      => 50,
            // 单个日志文件大小
            'file_size' => 1024*1024*10,
            // 使用JSON格式记录
            'json'           => true,
            // 日志处理
            'processor'      => null,
            // 关闭通道日志写入
            'close'          => false,
            // 时间格式化
            'time_format'   =>    'Y-m-d H:i:s',
            // 日志输出格式化
            'format'         => '[%s][%s] %s',
            // 是否实时写入
            'realtime_write' => true,
        ],
        // 数据库日志
        'sql' => [
            // 日志记录方式
            'type'           => 'File',
            // 日志保存目录
            'path'           => public_path() . "Logs/sql",
            // 单文件日志写入
            'single'         => true,
            // 独立日志级别
            'apart_level'    => [],
            // 最大日志文件数量
            'max_files'      => 50,
            // 单个日志文件大小
            'file_size' => 1024*1024*10,
            // 使用JSON格式记录
            'json'           => true,
            // 日志处理
            'processor'      => null,
            // 关闭通道日志写入
            'close'          => false,
            // 时间格式化
            'time_format'   =>    'Y-m-d H:i:s',
            // 日志输出格式化
            'format'         => '[%s][%s] %s',
            // 是否实时写入
            'realtime_write' => true,
        ],
    ],
];

使用Log::getLog()获取为空
使用Log::getLog('wechat')也是空的
请问是我哪里配置有问题吗?

@big-dream
Copy link
Contributor

测试正常

Log::debug('debug message');
halt(Log::getLog());

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants