4

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

3 Answers 3

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

Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

0
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.

For Example:- Displaying PHP errors in local machine

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.