Error Log Not Being Written

Hi all,

I'm trying to have PHP write all errors to a file (phperrors.log) but the file is not being written when an error occurs.  Maybe you can point out what I'm missing.

PHP.ini
----------------
error_reporting = E_ALL
display_errors = On   I'm leaving this on till I can get the file to write.
log_errors = On
log_errors_max_len = 0
error_log = ".:/Users/Me/Sites/phperrors.log"


Like I said, I'm visually seeing the errors but the log file isn't being written.

Thanks,
\m/
fatfeAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
ThGConnect With a Mentor Commented:
yes but not only. You also need to make sure that ALL the upper directories have "access permission" (+x) for the web user, generally included in the "o" (others) permissions. so:
chmod +x /Users
chmod +x /Users/Me
chmod +x /Users/Me/Sites
touch /Users/Me/Sites/phperrors.log
chmod 666 /Users/Me/Sites/phperrors.log
666 means read-write permission for all.
0
 
ThGCommented:
Why on earth are you using that syntax? can't you just use:
error_log = "/Users/Me/Sites/phperrors.log"

also make sure it is really writable by the web user, if you are unsure, try:
error_log = "/tmp/testing_errors.log"
0
 
fatfeAuthor Commented:
Thanks ThG,

I tried error_log = "/Users/Me/Sites/phperrors.log" and an error log was not created.
When I tried error_log = "/tmp/phperrors.log" the error log was written.  But what I want to get around is have to go to the command line to pull up the error log.  I would rather have it written to my user directory where I can easily pull it up in say TextEdit or some word processor.  I take it a change in permissions on that file would allow it be written to the location of my choosing?
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
fatfeAuthor Commented:
My Unix background isn't that strong.  So my question is in changing the permissions on ALL the upper directories leading to this error log file what type of access will other users have, if any, to these changed directories?

Thanks for the quick response.
0
 
ThGCommented:
+x means they will only be able to "cd" to your directory, but not list files (it could be insecure anyway, so you should store your error log somewhere else.
of course everyone will be able to write to your log file, given that they know the exact name.
0
 
e-tsikCommented:
Hi :-)

I know it's a long time, but I found your question in Google, and ran into the same problem myself.

As a rule of thumb, PHP does log, if you allow the apache user to write the file in that folder. For example, if you'd write the log to /tmp (e.g. /tmp/php.err.log) you certainly would not have any permission problems.

PHP Would NOT log if:
1. It has no write permissions the log file.
2. error_reporting is disabled, even with the PHP function(!). If you have somehow disabled error reporting, then put back on!
3. If you've used error trapping (using set_error_handler() )- then PHP would not log - it would count on you to log instead using the error_log function:
 function MyErrorHandler ($errno, $errstr, $errfile, $errline)
        {
                error_log("error: Errno: $errno; ErrStr: \"$errstr\"; ErrFile: \"$errfile\"; ErrLine: $errline");
..
.
.

Things to do:
1. Change your filename to "/tmp.php.err.log". Restart httpd and try log for that file.
2. Do a search for "error_reporting" both in /etc/my.ini (the PHP config file) and in your PHP files. Make sure there's nothing that sets it to 0 or E_NONE.
3. Do a search for "set_error_handler"  in your PHP files. If you see one, look for that function is sets to and put
   error_log("error: Errno: $errno; ErrStr: \"$errstr\"; ErrFile: \"$errfile\"; ErrLine: $errline");
   in the first line of the function.

Enjoy!
0
 
ThGCommented:
fatfe, thanks for grading this question. I hope you resolved your problem.

Regards
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.