PHP .htacces error logging

I want through PHP error logging to see my errors from my php codes. php_flag display_startup_errors on php_flag display_errors on php_flag html_errors on php_flag log_errors on php_value error_reporting 32767 php_value error_log /home/h51116rm/domains/h51116rm.informatica-laz.nl/public_html/PHP_errors.log
This is my PHP code in my htacces. But my PHP_errors.log stays empty if i try to open a PHP page with an error.

Maybe your host doesn’t allow you to overwrite the settings in .htaccess ?

Have you tried ini_set() to set the location of the error log and what categories of errors to log?

I have permission 755 on .htacces

What do you mean with that?

You keep spelling it htacces with only one s. You have spelled it correctly on your server?

Yeah i did, thanks for noticing that

I also have this in my .htaccess

Options -Indexes

Try viewing your php options:

http://php.net/manual/en/function.ini-get.php

Also force an error and check your log file

<?php

echo $x / $y;
echo  "hello world";
die;

There is nothing in my log file

…and the results of ini_get(“paremeter”); all correspond to the .htaccess file?

Try also setting error_reporting to -1 which is the maximum for all errors and warnings

<?php


echo 'display_errors = ' . ini_get("paremeter") . "\n";

Also, i can't access my php.ini file

?>

This shows up in the browser "display_errors = "

Read the link I posted because there are examples of how to use ini_get()

I believe setting the PHP parameters in .htaccess override the php.ini file settings

1 Like

Alright, i will look into it

1 Like

Are you sure you even have access to your php.ini or have permission to create one? The main problem I see is that you don’t have permission to make one and so that probably is why your custom error log is not working.

Mind me asking, is this locally or on a live server?

AFAIK htaccess can not handle logging.

You need control of
httpd.conf for server log settings
php.ini for PHP log settings

If you have a shared host it is highly unlikely that you will be able to mess with either.

It is possible (and IMHO a good idea) to have a PHP error handler

http://php.net/manual/en/function.set-error-handler.php

You won’t be able to log all errors, (eg. server) but it should be good enough for script errors.

Yeah i don’t have acces to php.ini, i will try what Mittineague sayed.

Live server

If you try:

ini_set('error_log','location_of_log');

replacing “location_of_log” with the location of your custom error log, then generate an error, does it appear in your custom error log

2 Likes

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.