Php error log not working correctly - php

i have error in my page but it is not logs in to the log file
i have set
display_errors:Off
display_startup_errors:Off
error_log:error_log
log_errors:On
i have restarted apache after configuration
but it is not working
just checked the apache file /etc/httpd/logs/error_log file
it contain the error but why the error_log does not creating in the folder in which error occurs

try this in your php file
ini_set("log_errors", 1);
ini_set("error_log",$_SERVER['DOCUMENT_ROOT']."/logs/php-error.log");
Give write permission to the folder logs and its file, then check the file in logs folder.
error_log:error_log
error_log not has correct path, set a correct path like below
log_errors = On
error_log = "C:\xampp\php\logs\php_error_log"

You said:
just checked the apache file /etc/httpd/logs/error_log file it contain the error ...
which means:
loggine php errors works
all errors are written to /etc/httpd/logs/error_log
You also said:
... but why the error_log does not creating in the folder in which error occurs
Your php.ini directove error_log specifies where your want your error log to be. Now it is default. Specify different log file location and you'll have it in different place. There is no why - it lands where it is said to be.

Related

Enabling php_error_log in Xampp

I'm having an issue where Xampp isn't logging my errors. The file path doesn't exist when I search for it. I read some stuff about this that said I need to enable php_error_log from the php.ini file but i don't know what values to change.
It should be a permissions issue (depending where you installed XAMPP). The XAMPP panel is sometimes unable to create the logs folder. Just create this directory:
...\xampp\php\logs
and the next time PHP error occurs it will create the php_error_log file inside and the logging will start.

Where do the logs go with error_log function?

I recently got already written php project, and I am trying to work on it. I can see that all logs are written to the specific location using file_put_contents() function.
But I can see that there's error_log() function in one place, without a destination file given. It looks like this:
error_log($str);
Where can I find logs file in this case?
The error log file is set with the error_log directoive in php.ini.
If the directive is not set, the file location is managed by the SAPI error logger, which in case of Apache it is in "Apache" logs directory.
You can find if this directive have a value with phpinfo()

Access error logs in Vagrant box to view 'internal server errors'

I have a vagrant box setup that and would like to debug some '500 internal server' errors I am receiving in Magento application
I see the log folder within my directory structure but cannot see any access.log or error.log files within this directory do I need to something to turn this on?
Remember the log files for errors is exception.log, and notice/warnings is system.log. Both files are under var/log of your magento installation.
Sometimes magento can not catch an error. In this case the error is either printed to the browser or saved to the Apache log. Checkout the apache log under /var/log/apache/ (file name may be pho_error.log, error.log as set in apache vhost config.

PHP not logging errors

I have tried two different things on my server:
created a directory php in /var/log/
changed owner:group to www-data:www-data (apache owner)
changed permissions of the directory to 775
php.ini has error_log = "/var/log/php/php.log"
php.ini already had error logging set to on, and error reporting set to all
restarted apache
in the code, changed error_log('message') to error_log('message',3,path_to_logfile)
Neither results in messages in the applicable log file.
You say you created /var/log, but you're trying to write to /var/log/php. Try creating a directory called php in /var/log.

Keep PHP error_log files outside of web root

Currently, when a PHP error occurs, it will log it into a file called error_log in the same directory the error occurred in.How can I keep the error_log files outside of the web root so that users cannot view them, for security?
Edit your php.ini file. Find the error_log setting and change it to the full path of where you want the error_log file to be written.

Categories