Page 1 of 2

HowTo Enable Reporting of PHP Errors and Warnings using Apache

Posted: Tue Mar 27, 2007 4:00 pm
by tcp
Overview

This thread introduces some basic tips about configuring PHP and Apache to give useful information about Joomla bugs.  Most installations of Apache and PHP will not, by default, give this information, but this can easily be changed.  Why enable reporting?  Because this information will indicate where PHP found a problem and helps us resolve the cause of the problem.

Your Current Settings

You may have error logging already.  To check using Joomla!1.5 , in the administrator application select Help -> System Info.  On the submenu, select PHP Information and search for error_log, error_reporting, and display_errors .  Both the local and global settings are show, but it is the local settings that matter when working with Joomla.  You should also note the Configuration File (php.ini) Path for future reference.

How to Change the Settings

As with anything there are many ways to enable PHP reporting of errors and warnings, and the tips below represent the way that I like to work.  Suggestions are welcomed.

Using Apache's 2.0 virtual hosting I have several sites on my local system, each with their own log files.  With these settings, all PHP errors are both displayed and logged to a file.  The php_flag and php_value directives can also be placed in an .htaccess file if the webserver permits the overriding of options.

Code: Select all

<VirtualHost *:80>
    ServerName joomla
    DocumentRoot /var/www/domains/joomla/html
    ErrorLog /var/www/domains/joomla/error_log
    CustomLog /var/www/domains/joomla/access_log common
    php_flag display_errors on
    php_value error_reporting 6143
    php_flag log_errors on
    php_value error_log /var/www/domains/joomla/php_log
</VirtualHost>
One can also enable these settings in the php.ini file.

Code: Select all

error_reporting  =  E_ALL
;error_reporting  =  E_ERROR
display_errors = On
;display_errors = Off
... and so on
If you are working on your own computer ( localhost ), then changing the Apache or PHP configurations may be as simple as opening the configuration file, making the changes, saving, and restarting the webserver.  Otherwise, you may or may not be able to make these changes depending on your hosting service, and you may want to contact their support team for advice.  You may still be able to enable error reporting using an .htaccess file.

Watching the Log File

The log file can easily be watched using a utility called tail which comes natively with most *nix distributions, including Linux and Mac OS X.  Windows users will need to install this utility ( cygwin or unxutils ).  When used, the PHP log file will look something like this:
Toby-Patterson:html $  tail -f /var/www/domains/joomla/php_log &
[27-Mar-2007 22:36:35] PHP Notice:  Trying to get property of non-object in /private/var/www/domains/joomla/html/components/com_content/helpers/content.php on line 347
[27-Mar-2007 22:36:35] PHP Notice:  Trying to get property of non-object in /private/var/www/domains/joomla/html/components/com_content/helpers/content.php on line 339
This information is incredibly useful to developers because it indicates exactly where PHP detected a problem.  Not all problems will result with additional entries in the log file ( poor code logic, JavaScript/Browser issues ), but most will.

Resources

PHP Configuration References:
http://www.php.net/manual/en/configuration.changes.php
http://www.php.net/manual/en/ini.php#ini.list
http://www.php.net/error_reporting
http://www.php.net/manual/en/ref.errorfunc.php

Apache Configuration References:
http://forum.joomla.org/index.php?topic=79277.0
http://httpd.apache.org/docs/2.0/mod/co ... owoverride

Utility References:
http://www.cygwin.com/
http://unxutils.sourceforge.net/

Final Thoughts

Again, this is merely an introduction and suggestions are welcomed.

Happy Debugging,

tcp

Note to moderators: Please feel free to edit this post with additional suggestions or links.

--edit March 28th - links to cygwin and unxutils

Re: HowTo Enable Reporting of PHP Errors and Warnings using Apache

Posted: Tue Mar 27, 2007 4:35 pm
by diri
cygwin is your friend in case of running some windish environment to get tools like tail. AFAIR at sourceforge one can find binaries only at mingw or similar packages.

Re: HowTo Enable Reporting of PHP Errors and Warnings using Apache

Posted: Wed Mar 28, 2007 11:47 am
by friesengeist
diri wrote: cygwin is your friend in case of running some windish environment to get tools like tail. AFAIR at sourceforge one can find binaries only at mingw or similar packages.
Native win32 port of "tail" and many others:
http://unxutils.sourceforge.net/ :)

Re: HowTo Enable Reporting of PHP Errors and Warnings using Apache

Posted: Tue Apr 10, 2007 5:39 am
by diri
An addition to make testing more comfortable while having multiple incarnations of Joomla! running on standalone machines or same server in LAN and behind a router being capable to support services like dyndns:

Most easy way to introduce name of a server in LAN is to use a local DNS. For small LANs and standalone machines this might be to much. "hosts" file is of help very much than.

Example hosts file to make one or more virtual hosts accessable with names:

Code: Select all

127.0.0.1 localhost joomla joomla2 joomla3
192.168.1.200 joomla.mylan.net joomla2.mylan.net joomla3.mylan.net
In Apache's configuration of virtual hosts:

Code: Select all

<VirtualHost *:80>
    ServerName joomla
    ServerAlias joomla.mylan.net
    DocumentRoot /var/www/domains/joomla/html
    ErrorLog /var/www/domains/joomla/error_log
    CustomLog /var/www/domains/joomla/access_log common
    php_flag display_errors on
    php_value error_reporting 6143
    php_flag log_errors on
    php_value error_log /var/www/domains/joomla/php_log
</VirtualHost>
<VirtualHost *:80>
    ServerName joomla2
    ServerAlias joomla2.mylan.net
    DocumentRoot /var/www/domains/joomla/html
    ErrorLog /var/www/domains/joomla2/error_log
    CustomLog /var/www/domains/joomla2/access_log common
    php_flag display_errors on
    php_value error_reporting 6143
    php_flag log_errors on
    php_value error_log /var/www/domains/joomla2/php_log
</VirtualHost>
<VirtualHost *:80>
    ServerName joomla3
    ServerAlias joomla3.mylan.net
    DocumentRoot /var/www/domains/joomla3/html
    ErrorLog /var/www/domains/joomla3/error_log
    CustomLog /var/www/domains/joomla3/access_log common
    php_flag display_errors on
    php_value error_reporting 6143
    php_flag log_errors on
    php_value error_log /var/www/domains/joomla3/php_log
</VirtualHost>
To make it accesable via dyndns and the like add a ServerAlias for each virtual host which should be accessable via internet. At this service provider one needs an entry for each hostname which should be connectable.

hth.

Re: HowTo Enable Reporting of PHP Errors and Warnings using Apache

Posted: Mon Jun 11, 2007 6:54 am
by micheas
Note that you can have more than one ServerAlias per virtual host.

Re: HowTo Enable Reporting of PHP Errors and Warnings using Apache

Posted: Fri Jul 06, 2007 7:37 pm
by CirTap
Hi,

in order for php_value and php_flag to work as intended (VirtualHost, .htaccess) PHP must run as the server module. The CGI version, which is used by the majority of ISPs, won't notice any of this.
Editing PHP.INI is usually prohibited in a shared environment, so it's not an option for many ppl.

However, any of PHP's error_* settings can also be set at runtime via script using ini_set() -- provided this function wasn't disabled (some ISPs believe this is a dangerous function and disable it in the configuration).

- display_errors
- display_startup_errors (only works in script if used in a "prepend_script")
- error_append_string
- error_log
- error_prepend_string
- error_reporting

Any php setting declared as PHP_INI_ALL may be changed in script: Appendix G. php.ini directives, see table H.2 at the end, and runtime settings

CirTap

Re: HowTo Enable Reporting of PHP Errors and Warnings using Apache

Posted: Tue Sep 25, 2007 11:53 am
by RonVA
It would be nice to include a guide on how to report a Joomla error. I guess there must be a structured way to do so. I want to report an 1.5 bug I just ran into but can't seam to figure out how. Maybe it's already solved so is there a repository somewhere to search?

Ron

Re: HowTo Enable Reporting of PHP Errors and Warnings using Apache

Posted: Thu Sep 27, 2007 10:18 am
by CirTap
RonVA wrote: It would be nice to include a guide on how to report a Joomla error. I guess there must be a structured way to do so. I want to report an 1.5 bug I just ran into but can't seam to figure out how. Maybe it's already solved so is there a repository somewhere to search?

Ron
right over there: http://forum.joomla.org/index.php/board,179.0.html
there are a bunch of stickies explaining how and where.

CirTap

Re: HowTo Enable Reporting of PHP Errors and Warnings using Apache

Posted: Fri Sep 28, 2007 3:25 pm
by RonVA
Hi CirTab,

You are pointing me to a subforum of 'Archived Boards - All boards closed'. Not a place where you would expect a bug report forum... Also 'Quality and Testing - Locked and Archived' sounds as if you cannot post there. A sticky note on this forum points to the Joomla! Developerforge to submit bugs but one has to be a registered developer to do so!

As a beginning Joomla-er (and as an experienced developer) I really think that bug reporting should be made much more accessible!  The 'Quality and Testing - Locked and Archived' has only around 30 subjects posted in 6 months. With so few bugreports it will take ages to reach a stable version. Maybe (hopefully) I'm overlooking something...

Ron

Re: HowTo Enable Reporting of PHP Errors and Warnings using Apache

Posted: Sat Sep 29, 2007 2:50 pm
by CirTap
Hi,

when I posted the link the forums were still open :)
It just happend that some Working Groups were closed. Although bug reports have been posted in that forum they were usually moved to the appropriate WG forum (dev, translatiion, docs, whatever). It has been merily an entry point rather than the archive of anything that went wrong in the last two years.
With so few bugreports it will take ages to reach a stable version.
don't worry, there have been more bug reports than you'd want to know about, so yes: you are overlooking something

I'm not sure if one (still) needs an account at JoomlaCode to add an item to the bug tracker -- which is the primary place to report bugs anyway ;) http://joomlacode.org/gf/project/joomla/tracker/
You may find all the "many bugs" you were looking for, not sure though if it will "take ages" until they're fixed.

Have fun,
CirTap

Re: HowTo Enable Reporting of PHP Errors and Warnings using Apache

Posted: Mon Oct 01, 2007 5:45 pm
by RonVA
Thanks Cirtap,

Yes, one has to register before submitting. Still think this is way to difficult to find for average users and most users won't take the time to register etc. I do think an easy to find simple bug reporter should be available, moderated by someone who can do the structured bug reporting in the bug tracker (and prevent the same bugs being tracked).

Ron

Re: HowTo Enable Reporting of PHP Errors and Warnings using Apache

Posted: Tue Oct 02, 2007 2:36 pm
by CirTap
RonVA wrote: Still think this is way to difficult to find for average users and most users won't take the time to register etc. I do think an easy to find simple bug reporter should be available
well, why not use this very forum then?
there's a "bug tracker template" available as a sticky. copy that text into a new post and add your findings.

CirTap

Re: HowTo Enable Reporting of PHP Errors and Warnings using Apac

Posted: Sun Feb 15, 2009 8:49 pm
by deleted user
it should be emphasized in this thread that it's GOOD SECURITY PRACTICE to take steps to make your error logs non-obvious and restricted or to just cut off all error reporting except when you need it.

Re: HowTo Enable Reporting of PHP Errors and Warnings using Apac

Posted: Sun Feb 15, 2009 10:15 pm
by micheas
While there are various reasons to disable logging, security is not one of them.

Protect your logs from access by any but those that need to read them.

Check your logs daily. (You probably want to have a few automated test emailed to you, like length of log files, Geocode of the computers that have accessed your webserver, 404 errors (url and total number), 500 errors (url and total number of times.) plus anything that is relevant to your site.

Security is partially reactive, and if you don't have logs, you are reacting without information.

Re: HowTo Enable Reporting of PHP Errors and Warnings using Apac

Posted: Sun Feb 15, 2009 10:41 pm
by deleted user
This is not about ACCESS logs, it is about ERROR logs, specifically PHP error logs, which are a rich source of information for crackers.

I would say the maximum preventative security measure with error logs is to shut down all error logging completely in situations where those logs are not going to be used or monitored. If you need that information, use them. If you don't need it, producing it and leaving it on the server makes it available for 1) nobody (which is pointless), or 2) someone who shouldn't see it (which is bad for you).

At a minimum, knock down the verbosity of the reporting, use unconventional folder/filenames for the logs, and lock down their permissions.

Aside from PHP error logs, Joomla and its extensions can also generate error log files. Same suggestions on those:
http://docs.joomla.org/Security_Checkli ... _and_files

Re: HowTo Enable Reporting of PHP Errors and Warnings using

Posted: Thu Mar 17, 2011 10:14 am
by zimhosts
Im not so sure if lm posting this in the right place and please do forgive me. I have a 1.5 template that lm using for my website and everythingvwirks well but the only problem is that it does not report syfstem information eg if u sign up as a new member, that default message in blue that tells you that your activation link has been sent, does not sdisplay at all. When l interchange the template the message appears. This is tje case with all general system messages including when for instance l use this mail sending component. If there is an error in the component, that typical blue msg doesnt appear with this template unless l substitute it. I believe this must be the template issue but l dont want to change it. Is there anything l myt need to type into tje template files? Please help as lm so stranded now. Hope to hear from you soon. Thank you

Re: HowTo Enable Reporting of PHP Errors and Warnings using

Posted: Fri Jul 08, 2011 4:53 am
by stevenheron
zimhosts wrote:Im not so sure if lm posting this in the right place and please do forgive me. I have a 1.5 template that lm using for my website and everythingvwirks well but the only problem is that it does not report syfstem information eg if u sign up as a new member, that default message in blue that tells you that your activation link has been sent, does not sdisplay at all. When l interchange the template the message appears. This is tje case with all general system messages including when for instance l use this mail sending component. If there is an error in the component, that typical blue msg doesnt appear with this template unless l substitute it. I believe this must be the template issue but l dont want to change it. Is there anything l myt need to type into tje template files? Please help as lm so stranded now. Hope to hear from you soon. Thank you
Try using jdoc

Code: Select all

<jdoc:include type="message" />

Re: HowTo Enable Reporting of PHP Errors and Warnings using

Posted: Wed Sep 07, 2011 6:52 am
by vb_reader
diri wrote:An addition to make testing more comfortable while having multiple incarnations of Joomla! running on standalone machines or same server in LAN and behind a router being capable to support services like dyndns:

Most easy way to introduce name of a server in LAN is to use a local DNS. For small LANs and standalone machines this might be to much. "hosts" file is of help very much than.

Example hosts file to make one or more virtual hosts accessable with names:

Code: Select all

127.0.0.1 localhost joomla joomla2 joomla3
192.168.1.200 joomla.mylan.net joomla2.mylan.net joomla3.mylan.net
That is really a good tip for me. This reduces lots work working on internal networks.

Re: HowTo Enable Reporting of PHP Errors and Warnings using

Posted: Thu Sep 15, 2011 6:12 am
by allen012087
i have enabled the error reporting to the maximum and under the footer i get a large section of codes i can see., all these are errors?
•Profile Information•
....

•Memory Usage•
....
•20 queries logged.•
...
•0 legacy queries logged.•

•Language Files Loaded•
....
•Untranslated Strings Diagnostic•

•None•

•Untranslated Strings Designer•

•None•


all under these headings are errors? is it similar to logs or different? do i need to know codes to understand them and fix it or is there any software tools available to fix them? thanks

Re: HowTo Enable Reporting of PHP Errors and Warnings using

Posted: Fri Oct 21, 2011 11:10 am
by laura_abc
thaanks, it was a very-very big help also for us! :laugh:

i'm glad to find this!

Re: HowTo Enable Reporting of PHP Errors and Warnings using

Posted: Tue Dec 13, 2011 3:39 pm
by sh4n0n
looking for this since quiet a long time, comes in handy!
thanks for writing it up! :)
Image

regards,
shanon

Re: HowTo Enable Reporting of PHP Errors and Warnings using

Posted: Tue Dec 20, 2011 2:18 am
by Concha_Enferma
zimhosts wrote:Im not so sure if lm posting this in the right place and please do forgive me. I have a 1.5 template that lm using for my website and everythingvwirks well but the only problem is that it does not report syfstem information eg if u sign up as a new member, that default message in blue that tells you that your activation link has been sent, does not sdisplay at all. When l interchange the template the message appears. This is tje case with all general system messages including when for instance l use this mail sending component. If there is an error in the component, that typical blue msg doesnt appear with this template unless l substitute it. I believe this must be the template issue but l dont want to change it. Is there anything l myt need to type into tje template files? Please help as lm so stranded now. Hope to hear from you soon. Thank you
You might have to also add the rest of the code, like this

Code: Select all

<?php if ($this->getBuffer('message')) : ?>
<div class="info"> <jdoc:include type="message" /> </div>
<?php endif; ?>
See if that works, otherwise send me a PM and I'll see if we can work it out together.

Re: HowTo Enable Reporting of PHP Errors and Warnings using

Posted: Tue Dec 27, 2011 5:08 am
by Fonias
You can't imagine how happy you make me now! I was looking for a workaround but didn't find anything else except of this!

Thank you and have a Happy New Year!

Re: HowTo Enable Reporting of PHP Errors and Warnings using

Posted: Tue Jan 03, 2012 6:42 pm
by ronaldwilli
Concha_Enferma wrote:
zimhosts wrote:Im not so sure if lm posting this in the right place and please do forgive me. I have a 1.5 template that lm using for my website and everythingvwirks well but the only problem is that it does not report syfstem information eg if u sign up as a new member, that default message in blue that tells you that your activation link has been sent, does not sdisplay at all. When l interchange the template the message appears. This is tje case with all general system messages including when for instance l use this mail sending component. If there is an error in the component, that typical blue msg doesnt appear with this template unless l substitute it. I believe this must be the template issue but l dont want to change it. Is there anything l myt need to type into tje template files? Please help as lm so stranded now. Hope to hear from you soon. Thank you
You might have to also add the rest of the code, like this

Code: Select all

<?php if ($this->getBuffer('message')) : ?>
<div class="info"> <jdoc:include type="message" /> </div>
<?php endif; ?>
See if that works, otherwise send me a PM and I'll see if we can work it out together.
Ok I have tried the above and yes it does work. However after this change my page looks little misaligned. Should I need to make anymore changes.

Thank you so much for helping.

Re: HowTo Enable Reporting of PHP Errors and Warnings using

Posted: Mon Jan 16, 2012 5:44 pm
by ronaldwilli
OK the misalignment fixed. It is the problem with my old browser MSIE at the workplace. Now in home i am working on IE9 and it displays in proper alignment.

Thank you for the great responses helped me out.

Re: HowTo Enable Reporting of PHP Errors and Warnings using

Posted: Sat Jan 28, 2012 9:07 am
by raghavmitra
ronaldwilli wrote:OK the misalignment fixed. It is the problem with my old browser MSIE at the workplace. Now in home i am working on IE9 and it displays in proper alignment.

Thank you for the great responses helped me out.
Do you really think this thread concerns alignment problems in joomla? :-\
Read the full thread before posting buddy.

@tcp , thanks that really helped a lot. ;)

Re: HowTo Enable Reporting of PHP Errors and Warnings using

Posted: Sun Feb 05, 2012 1:10 pm
by stevegd
my webserver log file was full of huge chunks of php errors about 20Mb worth in 3 days alone. I reported this to my developer who after viewing my php info details pointed out that my php error_log value is set to 6154 what is this value? will a lower value supress some of the error logs? I dont want to turn off php error logging completley

Re: HowTo Enable Reporting of PHP Errors and Warnings using

Posted: Fri Feb 24, 2012 1:34 pm
by louisjunwe
Glad to find the useful info about Apache Configuration & Utility References, thanks for sharing these useful sites.

Re: HowTo Enable Reporting of PHP Errors and Warnings using

Posted: Sun Mar 11, 2012 8:08 am
by tittbit
stevegd wrote:my webserver log file was full of huge chunks of php errors about 20Mb worth in 3 days alone. I reported this to my developer who after viewing my php info details pointed out that my php error_log value is set to 6154 what is this value? will a lower value supress some of the error logs? I dont want to turn off php error logging completley
for that you can set a cron job to delete log files

for your referenece you can use following cron command

find /public_html/error/ -type f -mtime +10 -name "*.log" | xargs rm -f > /public_html/error/purgelog.txt


assuming that log file is in directory "error"under public_html folder and log file name is purgelog.txt

Re: HowTo Enable Reporting of PHP Errors and Warnings using

Posted: Sat Apr 21, 2012 4:06 am
by aakashdavis
Nice thread got some really wonderful resources here. Thanks all