'Log PHP error Into file in xampp localhost using .htaccess
I need to log PHP error to .log file using .htaccess with log_errors:
# supress php errors
php_flag display_startup_errors off
php_flag display_errors off
php_flag html_errors off
# enable PHP error logging
php_flag log_errors on
php_value error_log C:\xampp\htdocs\cms\cache\logs\PHP_errors.log
# prevent access to PHP error log
<Files PHP_errors.log>
Order allow,deny
Deny from all
Satisfy All
</Files>
Now, This not work and .log file is empty.
NOTE:I change .log file to 777 permission.
I know, xampp log PHP error to this file : C:\xampp\php\logs\php_error_log.log
Solution 1:[1]
maybe it's too late for the answer but I hope it can be useful.
have you tried checking apache's httpd.conf file? Mine contains these lines:
LogLevel error
ErrorLog /app/logs/apache/error/my_log_file.log
CustomLog /app/logs/apache/access/my_log_file.log combined
These lines keep overriding .htaccess configuration, maybe this is also your case...
Hoping to be helpful
Solution 2:[2]
So I don't like using htaccess for things like error logging but I am not sure if you cannot use PHP or whatever. I typically just use PHP to handle error logging. It gives you a LOT of power. For just one example you don't want a HUGE file with tons of errors - which would happen if the logs weren't maintained properly. At least using PHP you can use a database or file storage with a little more power. The database method is probably the most preferred (by me at least). However, again you've got to keep up with logs and remove old logs to prevent database bloating. If you did decide to use file storage then using PHP would be a better method because of the possibilities. You could make sure the log never exceeds a certain file size, export old logs and start a new file and much much more....
Here's a link that can get you started. PHP Custom Error Handling
Solution 3:[3]
Displaying PHP errors [ In localhost or local machine ]
How to log, all the PHP errors to the specific location
3 ways to see PHP errors :
1) add a script to the PHP file.
ini_set("display_errors", "1");
error_reporting(E_ALL);
2) Create a .htaccess file in your project root directory.
php_flag display_startup_errors on
php_flag display_errors on
php_value error_log logs/all_errors.log
3) Create a logs folder in your project root directory.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | morepaolo |
| Solution 2 | Tyler |
| Solution 3 | Sonu Chohan |

