在Debian系统中管理ThinkPHP日志,可参考以下技巧:
日志配置
config/log.php
,设置日志路径(默认runtime/log/
)、级别(如['error', 'warning']
)、格式等。日志查看
runtime/log/
目录下的日志文件。php think log
:查看所有日志。grep "关键字" runtime/log/*.log
:筛选特定日志。日志清理
crontab
设置定时任务自动清理。max_files
参数限制日志文件数量,避免磁盘占满。高级管理
tail -f
命令实时监控日志,或使用ELK等工具进行集中化分析。权限与安全
runtime/log/
目录权限为755
,避免写入异常。参考来源: