| 
   
   | 
    | 
  
   
    
error_log    (PHP 3, PHP 4, PHP 5) error_log -- Send an error message somewhere Описаниеbool  error_log ( string message [, int message_type [, string destination [, string extra_headers]]] ) 
   Sends an error message to the web server's error log, a
   TCP port or to a file.
   Список параметров
    - message
 
       The error message that should be logged.
       - message_type
 
       Says where the error should go. The possible message types are as 
       follows:
       
        Таблица 1. error_log() log types | 0 | 
            message is sent to PHP's system logger, using
            the Operating System's system logging mechanism or a file, depending
            on what the error_log
            configuration directive is set to.  This is the default option.
            |  | 1 | 
            message is sent by email to the address in
            the destination parameter.  This is the only
            message type where the fourth parameter,
            extra_headers is used.
            |  | 2 | 
            message is sent through the PHP debugging
            connection.  This option is only available if remote debugging has
            been enabled.  In this case, the
            destination parameter specifies the host name
            or IP address and optionally, port number, of the socket receiving
            the debug information. This option is only available in PHP 3.
            |  | 3 | 
            message is appended to the file
            destination. A newline is not automatically 
            added to the end of the message string.
            |  
  
      - destination
 
       The destination. Its meaning depends on the 
       message parameter as described above.
       - extra_headers
 
       The extra headers. It's used when the message
       parameter is set to 1.
       This message type uses the same internal function as 
       mail() does.
       
  
  Примеры
    Пример 1. error_log() examples | 
 
<?php 
if (!Ora_Logon($username, $password)) { 
    error_log("Oracle database not available!", 0); 
} 
 
if (!($foo = allocate_new_foo())) { 
    error_log("Big trouble, we're all out of FOOs!", 1, 
               "operator@example.com"); 
} 
 
error_log("You messed up!", 2, "127.0.0.1:7000"); 
error_log("You messed up!", 2, "loghost"); 
error_log("You messed up!", 3, "/var/tmp/my-errors.log"); 
?>
  |  
  |   
  
  
 
  error_log
  
 
 
  marques at displague dot com
  26-Aug-2005 01:52
  
Beware the size of your custom error_log! 
 
Once it exceeds 2GB the function errors, ending your script at the error_log() line.  I'm sure this differs from OS to OS, but I have seen it die writing to ext2 under modern Linux systems.
 
   
  
 
 
  mac at codegreene dot com
  08-Aug-2005 09:33
  
When outputting to syslog, it uses the syslog() function, which limits its output to 500 characters. We have been able to send multi-line output to the log, but newlines appear to be replaced with a space in the output, and output is cut off at 500 characters. 
 
A simple workaround for long, multi-line output is something like this: 
 
$errlines = explode("\n",$errmsg); 
foreach ($errlines as $txt) { error_log($txt); }
 
   
  
 
 
  php at kennel17 dot NOSPAM dot co dot uk
  25-Jul-2005 02:04
  
It appears that the system log = stderr if you are running PHP from the command line, and that often stderr = stdout.  This means that if you are using a custom error to both display the error and log it to syslog, then a command-line user will see the same error reported twice.
 
   
  
 
 
  kazezb at nospam dot carleton dot edu
  21-Jul-2005 10:39
  
It appears that error_log() only logs the first line of multi-line log messages. To log a multi-line message, either log each line individually or write the message to another file.
 
   
  
 
 
  franz at fholzinger dot com
  20-Apr-2005 09:21
  
In the case of missing your entries in the error_log file: 
When you use error_log in a script that does not produce any output, which means that you cannot see anything during the execution of the script, and when you wonder why there are no error_log entries produced in your error_log file, the reasons can be: 
- you did not configure error_log output in php.ini 
- the script has a syntax error and did therefore not execute
 
   
  
 
 
  28-Mar-2003 02:14
  
when using error_log to send email, not all elements of an extra_headers string are handled the same way.  "From: " and "Reply-To: " header values will replace the default header values. "Subject: " header values won't: they are *added* to the mail header but don't replace the default, leading to mail messages with two Subject fields. 
 
<?php 
 
error_log("sometext", 1, "zigzag@my.domain",  
  "Subject: Foo\nFrom: Rizzlas@my.domain\n"); 
 
?> 
 
---------------%<----------------------- 
To: zigzag@my.domain 
Envelope-to: zigzag@my.domain 
Date: Fri, 28 Mar 2003 13:29:02 -0500 
From: Rizzlas@my.domain 
Subject: PHP error_log message 
Subject: Foo 
Delivery-date: Fri, 28 Mar 2003 13:29:03 -0500 
 
sometext 
---------------%<--------------------- 
 
quoth the docs: "This message type uses the same internal function as mail() does."   
 
mail() will also fail to set a Subject field based on extra_header data - instead it takes a seperate argument to specify a "Subject: " string. 
 
php v.4.2.3, SunOS 5.8
 
   
  
 
 
  dan at mojavelinux dot com
  31-Jan-2003 11:46
  
I find it very suprising that there are no PHP constants (or references to them if they exist) for the log types.  I would expect 
 
SYSTEM_LOG = 0 
TCP_LOG = 1 
FILE_LOG = 2 
MAIL_LOG = 3 
 
or something to that nature.  Are we going to see this in any future versions?  Seems very silly to use integers here when they could easily be changed or confused.
 
   
  
  
 |    |