简体   繁体   English

PHP - 通过 htaccess 记录错误 - 错误 500

[英]PHP - error logging through htaccess - Error 500

I'm trying to log all PHP errors by activating the logging in htaccess but for some reason, I always end up with a http 500 error.我试图通过激活 htaccess 中的日志记录来记录所有 PHP 错误,但由于某种原因,我总是以 http 500 错误告终。

I have stored the .htaccess in a separate directory to avoid messing up with the rest of my site.我将 .htaccess 存储在一个单独的目录中,以避免与我网站的其余部分混淆。

The content of the .htaccess file is the following: .htaccess 文件的内容如下:

php_flag display_errors off 
php_flag log_errors On 
php_value error_log /home/xxxxx/www/cache/php_logs/errors.log

The path exists and permissions are set to 777路径存在,权限设置为777

In my PHP file I have only:在我的 PHP 文件中,我只有:

<?PHP
  echo "hello world";
?>

If I remove the content of the .htaccess file, I can see "hello world" but as soon as I activate logging, it ends up with an internal server error (error 500).如果我删除 .htaccess 文件的内容,我可以看到“hello world”,但是一旦我激活日志记录,它就会以内部服务器错误(错误 500)结束。

Is there something I'm missing?有什么我想念的吗?

Thanks谢谢

It looks like this method is no longer supported (using htaccess for logging).似乎不再支持此方法(使用 htaccess 进行日志记录)。 I have found an alternative that does the same:我找到了一种替代方法:

  • create a .user.ini file in my root directory在我的根目录中创建一个 .user.ini 文件
  • add logging in the .user.ini file:在 .user.ini 文件中添加日志:
 log_errors = On error_log = /home/xxxx/www/cache/php_logs/errors.log

By doing this, it will log all errors in the specified directory and it works with shared hosting solutions.通过这样做,它将记录指定目录中的所有错误,并与共享托管解决方案一起使用。 (at least with mine). (至少我的)。

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

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