日志系统
ThinkPHP 提供了完善的日志记录功能。
配置日志
编辑 config/log.php:
php
<?php
return [
'default' => 'file',
'channels' => [
'file' => [
'type' => 'File',
'path' => '../runtime/log/',
'level' => ['error', 'warning', 'info'],
],
],
];
?>记录日志
php
<?php
use think\facade\Log;
// 记录不同级别
Log::error('错误信息');
Log::warning('警告信息');
Log::info('信息');
Log::debug('调试信息');
// 记录数组
Log::info('用户数据', ['user_id' => 1, 'name' => 'John']);
?>日志级别
emergency- 紧急alert- 警报critical- 严重error- 错误warning- 警告notice- 通知info- 信息debug- 调试
下一步
学习多应用模式 → 多应用模式
