PHP
  Home arrow PHP arrow Page 7 - Logging With PHP
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PHP

Logging With PHP
By: icarus, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 34
    2002-11-27


    Table of Contents:
  • Logging With PHP
  • The Bare Necessities
  • Turning The Tables
  • Turning Up The Heat
  • Biting Into A PEAR
  • Destination Unknown
  • Artificial Intelligence
  • Big Brother Is Watching
  • Closing Time

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Logging With PHP - Artificial Intelligence
    ( Page 7 of 9 )

    You can also configure PHP to automatically log all script errors to a specific file via the special "log_errors" configuration directive in "php.ini". This directive, when set to true, logs all PHP errors to either a user-specified log file (the value of this file must be specified in the "error_log" configuration directive, also set via "php.ini"), or to the Web server error log if no log file is specified.

    Consider the following example, which demonstrates:

    <?php // turn on automatic error logging ini_set('log_errors', true); // include non-existent file include("non.existent.file.php"); ?>
    In this case, I'm manually instantiating an error by attempting to include a file which does not exist. Obviously, PHP will barf and display an error screen containing the following:

    Warning: Failed opening 'non.existent.file.php' for inclusion (include_path='.;/usr/local/php/includes') in error.php on line 10
    The same error also appears in the server's error log:

    [Tue Nov 26 12:49:31 2002] [error] PHP Warning: Failed opening 'non.existent.file.php' for inclusion (include_path='.;/usr/local/php/includes') in error.php on line 10
    You can turn off PHP error display, and only have the error message appear in the log file, by setting the "display_errors" variable (also accessible via "php.ini") to false. Consider the following variant of the previous example, which demonstrates:

    <?php // turn on automatic error logging ini_set('log_errors', true); // turn off error display ini_set('display_errors', false); // include non-existent file include("non.existent.file.php"); ?>
    In this case, though an error takes place, it is never displayed to the user, but merely gets logged to the server's error log.

    On *NIX systems, setting the "error_log" variable to the special value "syslog" logs all errors via the standard "syslog" daemon.

     
     
    >>> More PHP Articles          >>> More By icarus, (c) Melonfire
     

       

    PHP ARTICLES

    - Building Dynamic Queries with Chainable Meth...
    - PHP Encryption and Decryption Methods
    - Building a MySQL Abstraction Class with Meth...
    - Completing a Sample String Processor with Me...
    - Mastering WHILE Loops for PHP and MySQL
    - Method Chaining: Adding More Methods to the ...
    - Method Chaining in PHP 5
    - The Role of Interfaces in Applying the Depen...
    - Dependency Injection: Using a Setter Method ...
    - Using a Model Class with the Dependency Inje...
    - Injecting Objects Using Setter Methods with ...
    - Injecting Objects by Constructor with the De...
    - The Dependency Injection Design Pattern in P...
    - Performing Inferential Statistical Analysis ...
    - Performing Descriptive Statistical Analysis ...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
    Stay green...Green IT