2

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

8
  • can you identify the errors that appears ? Commented Nov 20, 2013 at 7:29
  • yes i made mistake my self to test that but it doesn't logged is also try to put error using this function but this too not worked error_log('An error'); Commented Nov 20, 2013 at 7:30
  • Well, what does the http servers configuration say about which error log file is used? Commented Nov 20, 2013 at 7:31
  • where i have to look for that Commented Nov 20, 2013 at 7:34
  • did you set path for error_log? Commented Nov 20, 2013 at 7:34

2 Answers 2

5

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"
Sign up to request clarification or add additional context in comments.

5 Comments

give all permission to the folder logs and its files and try again
friend this worked is set 777 permission on folder logs and file php-error.log but i have to include this two line every time i write any new file please why this is to be done and what permission will be safe to give
you can write these lines in separate file and include this in all files like a db connection file and keep the log in separate folder and give permission to this. I don't think it will be harmful.
do you have any idea why the correct php.ini settings are not working and we have to set seprately
log_errors = On error_log = "D:\xampp\php\logs\php_error_log" use this in php.ini it will work
0

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.

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.