Forum Moderators: phranque

Message Too Old, No Replies

error logs question

         

omoutop

12:39 pm on Jun 18, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



using phpinfo() i found that my www root is actually something like /home/sites/site130/www

as soon as i use ftp to log into the site i see the following folders:
- www
- logs
- cgi-bin
- users

so, i thought to set up an error log file (first time i do this, since in other cases the hosting server provided me with access to such a file)

In my htaccess file, at the very bottom of it, i added:

php_flag log_errors on
php_value error_log /home/sites/site130/logs/error.log

Yet after 2 days i have this up and running, i see nothing.
It the above approach good?
Or is it possible that no erros occured yet?

SteveWh

6:08 am on Jun 19, 2011 (gmt 0)

10+ Year Member



It's possible there just haven't been any errors.

The quickest way to test it is to write a short PHP script with an intentional error in it. Just misspell a function name or something. Then call the script with your browser to run it, and see if the error appears in your log file.

lucy24

7:09 am on Jun 19, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Check your regular logs. Everything that isn't a 200 should show up in the error log as well. And unless you've got the world's greatest firewall-- or you hold open house in your www site ;)-- there should at least be some 403s in there. If there aren't, I'd be happy to send you my Ukrainian robot.

tangor

7:57 am on Jun 19, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Check with your ISP regarding log procedures. Most times I find the ordinary logs to be very informative and have never felt the urge to modify either the access or error logs.

omoutop

5:44 am on Jun 20, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



thank you all for your responces
isp provides me with access logs only - these are many MB per day, difficult to download and check often
thats why i need a simple error log only

SteveWh

10:00 am on Jun 20, 2011 (gmt 0)

10+ Year Member



You might already know this, but the log you are setting up using the php_flag and php_value directives will only log PHP errors which are different types of errors than are shown in your HTTP access log. The PHP error log won't show HTTP response errors like 404-Not Found or 403-Forbidden, etc.

If you want to log all PHP errors and warnings (instead of only the most important errors), you could add this to the lines you already have:

php_value error_reporting 2147483647

----

Example code for testing whether your PHP error log is working. Create a file with just this code, run it from your browser, and check the error log:

<?php
eco "Hello World!";
?>

omoutop

10:14 am on Jun 20, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



yes, i know that
i just using php errors to test if i can actually create my own error logs in the specified folder

my final purpose is to have a log file that will include php + mod_rewrite erros + some custom routines i need

Up to now, the folder /logs/ seems unwritable

SteveWh

11:16 am on Jun 20, 2011 (gmt 0)

10+ Year Member



It could be unwritable if the folder is owned by your userID, and PHP (which has a different userID) is trying to create a new file in it.

The folder being unwritable means that PHP can't create a new file there, but it is still possible to manually create a file in that folder that *can* be written to by PHP:

Use your control panel's File Manager to manually create the file
/logs/error.log

The file will be owned by your userID.

In File Manager, set the permissions of the error.log file to 666 (rw-rw-rw-). This makes it possible for PHP to write data into the file.

It is a minor security risk because it has the side effect of allowing all the other userID's on your shared server to write to it, too, but shared servers are not typically full of malicious users who would do that. A malicious script in a hacked website on the server could also write to the file, but, again, that is not a rampant scenario.

With the PHP configuration that you seem to have, this is the only way to allow PHP (or Apache) to write to a file that your userID owns.

A small amount of protection would be to name the file something more complicated and less obvious than "error.log".