繁体   English   中英

php设置错误日志

[英]php setting an error log

我很难强迫我的应用程序记录错误。 这是文件层次结构:

/opt
  +-lampp
      +-htdocs
        +-project
          +-app
          | +-config
          | | +-errors.php
          | +-controllers
          | +-log
          | | +-error.log
          | +-etc...
          | +-index.php
          +-pub

这是errors.php:

<?php
/*
 * This is configuration for error handling
 */

ini_set('safe_mode','off');
//to display errors in browser, set 1
ini_set('display_errors',1);
//to write errors to a  log file, set 1
ini_set('log_errors',1);
//set default file to log errors
ini_set('error_log','app/log/error.log');
//error reporting level, set to E_ALL to see all errors and notices
//error_reporting(E_ALL);
error_reporting(E_ERROR|
        E_WARNING|
        E_CORE_ERROR|
        E_CORE_WARNING|
        E_COMPILE_ERROR|
        E_COMPILE_WARNING|
        E_USER_ERROR|
        E_USER_WARNING|
        E_STRICT|
        E_RECOVERABLE_ERROR|
        E_DEPRECATED|
        E_USER_DEPRECATED);
error_log('hi');

我在某些文章中读到,这可能是由安全模式引起的,所以我拒绝了它,但是它什么也没有改变。

还有一个想法,我的路径可能是错误的,在这种情况下,应该是什么?

我意识到以前曾问过这个问题,但我已经阅读了这些文章,但它们并没有帮助我。 即使这是一个“调试我的代码”问题,有人可以帮助我吗?

(ps确认error.php文件已到达并执行。)(pps error.php包含在index.php中)

编辑:

所以我评论了安全模式行并转储了这些行:

error_reporting => int(22527)

error_log => bool(true)

谢谢你的贴子,我从中学到了很多东西。 当我尝试绝对路径时,我发现问题出在文件权限上。 我要做的就是

sudo chmod 777 error.log

无论如何,在项目目录中拥有777权限的文件是一个好主意吗?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM