SunQuest
 
       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  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Actuate Whitepapers 
VeriSign Whitepapers 
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: 4 stars4 stars4 stars4 stars4 stars / 28
    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:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb 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

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    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


       · I like the simple example that loggs to a file and with a small modification, we can...
       · This is a great stuff...But how can we make the log file thus created write...
       · This should do it:[code]function log_action($msg) { $today =...
       · This should do it:[code]function log_action($msg) { $today =...
     

       

    PHP ARTICLES

    - Viewing and Editing Tasks for a Project Mana...
    - More on Private Methods with PHP 5 Member Vi...
    - Adding Tasks to a Project Management Applica...
    - Utilizing Private Methods with PHP 5 and Mem...
    - Making Changes in a Project Management Appli...
    - Defining Public and Protected Methods with M...
    - HTML for a Project Management Application
    - Using Subclasses and Accessors with Member V...
    - Implementing Internet Protocols with PHP
    - Project Management: The Application
    - Working with Private Properties to Protect P...
    - Protecting PHP 5 Class Data with Member Visi...
    - Setting Up a Web-based Image Hosting Service
    - Comparing Files and Databases with PHP Bench...
    - Setting Up a Web-Based Image Gallery





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway