Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Error Log Not Being Written

Posted on 2004-04-13
7
249 Views
Last Modified: 2008-03-10
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/
0
Comment
Question by:fatfe
  • 4
  • 2
7 Comments
 
LVL 14

Expert Comment

by:ThG
ID: 10818562
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
 

Author Comment

by:fatfe
ID: 10819242
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
 
LVL 14

Accepted Solution

by:
ThG earned 125 total points
ID: 10819259
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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:fatfe
ID: 10819317
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
 
LVL 14

Expert Comment

by:ThG
ID: 10825958
+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
 
LVL 9

Expert Comment

by:e-tsik
ID: 11443304
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
 
LVL 14

Expert Comment

by:ThG
ID: 12406597
fatfe, thanks for grading this question. I hope you resolved your problem.

Regards
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question