php – 如何将调试消息写入Silverstripe日志文件
发布时间:2020-12-13 22:06:20 所属栏目:PHP教程 来源:网络整理
导读:我有一个正在开发的Silverstripe 3.1站点,并希望将消息写入默认日志文件 – silverstripe.log 这是我们用来向屏幕输出变量或消息的方法: Debug::show($variable);Debug::message("Debug message goes here"); 将这些输出到silverstripe.log文件的最简单方法
我有一个正在开发的Silverstripe 3.1站点,并希望将消息写入默认日志文件 – silverstripe.log
这是我们用来向屏幕输出变量或消息的方法: Debug::show($variable); Debug::message("Debug message goes here"); 将这些输出到silverstripe.log文件的最简单方法是什么?我一直在查看文档,找不到正确的方法:http://doc.silverstripe.com/framework/en/topics/debugging 解决方法
您可以执行以下操作:
在mysite / _config.php中 SS_Log::add_writer(new SS_LogFileWriter('silverstripe.log'),SS_Log::WARN,'>'); 在你的代码中: SS_Log::log("Dammit,an issue with variable ".$var,SS_Log::WARN); 更多在http://doc.silverstripe.com/framework/en/topics/error-handling 另外,阅读框架/ dev / Log.php中的代码可以让您更深入地了解优先级的工作原理. PS:确保在apache用户可写的文件夹中定义’silverstripe.log’ (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |