ThinkPHP 日志管理
2022-07-28 14:14:58
112
{{single.collect_count}}

1、在配置文件 /config/log.php

return ['default'=> 'file',// 默认日志记录通道'level'=> [],// 日志记录级别'type_channel' => [],// 日志类型记录的通道 ['error'=>'email',...]// 日志通道列表'channels' => ['file' => ['type'=> 'File', // 日志记录方式'path'=> '',// 日志保存目录 'single'=> false, // 单文件日志写入'apart_level' => [],// 独立日志级别// 最大日志文件数量(推荐使用,建设服务器内存消耗,不然可能会导致服务器内存不足,网站卡死) 'max_files' => 0, 'file_size' => 1024*1024*10,//日志内容大小'realtime_write'=>true,// 实时写入(不推荐)], ],];

2、示例(默认保存在\runtime\log文件夹下面)

Log::write('测试日志信息,这是警告级别,并且实时写入',保存的文件地址);

3、总结

建议开启日志最大文件数量,不然之后用户量访问多的话 可能服务器的内存会不够导致网站访问卡死

回帖
全部回帖({{commentCount}})
{{item.user.nickname}} {{item.user.group_title}} {{item.friend_time}}
{{item.content}}
{{item.comment_content_show ? '取消' : '回复'}} 删除
回帖
{{reply.user.nickname}} {{reply.user.group_title}} {{reply.friend_time}}
{{reply.content}}
{{reply.comment_content_show ? '取消' : '回复'}} 删除
回帖
收起
没有更多啦~
{{commentLoading ? '加载中...' : '查看更多评论'}}