<HTML ><HEAD ><TITLE >error_log</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.44"><LINK REL="HOME" TITLE="PHP Manual" HREF="manual.html"><LINK REL="UP" TITLE="PHP options & information" HREF="ref.info.html"><LINK REL="PREVIOUS" TITLE="PHP options & information" HREF="ref.info.html"><LINK REL="NEXT" TITLE="error_reporting" HREF="function.error-reporting.html"></HEAD ><BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >PHP Manual</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="ref.info.html" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.error-reporting.html" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="function.error-log" >error_log</A ></H1 ><DIV CLASS="refnamediv" ><A NAME="AEN22973" ></A >error_log -- send an error message somewhere</DIV ><DIV CLASS="refsect1" ><A NAME="AEN22976" ></A ><H2 >Description</H2 ><DIV CLASS="funcsynopsis" ><P ></P ><CODE CLASS="FUNCDEF" >int error_log</CODE >(string message, int message_type, string [<SPAN CLASS="optional" >destination</SPAN >] , string [<SPAN CLASS="optional" >extra_headers</SPAN >] );<P ></P ></DIV ><P > Sends an error message to the web server's error log, a <SPAN CLASS="acronym" >TCP</SPAN > port or to a file. The first parameter, <TT CLASS="parameter" ><I >message</I ></TT >, is the error message that should be logged. The second parameter, <TT CLASS="parameter" ><I >message_type</I ></TT > says where the message should go: <DIV CLASS="table" ><P ><B >Table 1. <B CLASS="function" >error_log()</B > log types</B ></P ><TABLE BORDER="1" CLASS="CALSTABLE" ><TR ><TD ALIGN="LEFT" VALIGN="MIDDLE" >0</TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" > <TT CLASS="parameter" ><I >message</I ></TT > is sent to PHP's system logger, using the Operating System's system logging mechanism or a file, depending on what the <A HREF="configuration.html#ini.error-log" >error_log</A > configuration directive is set to. </TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="MIDDLE" >1</TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" > <TT CLASS="parameter" ><I >message</I ></TT > is sent by email to the address in the <TT CLASS="parameter" ><I >destination</I ></TT > parameter. This is the only message type where the fourth parameter, <TT CLASS="parameter" ><I >extra_headers</I ></TT > is used. This message type uses the same internal function as <B CLASS="function" >Mail()</B > does. </TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="MIDDLE" >2</TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" > <TT CLASS="parameter" ><I >message</I ></TT > is sent through the PHP debugging connection. This option is only available if <A HREF="install-unix.html#enable-debugger" >remote debugging has been enabled</A >. In this case, the <TT CLASS="parameter" ><I >destination</I ></TT > parameter specifies the host name or IP address and optionally, port number, of the socket receiving the debug information. </TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="MIDDLE" >3</TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" > <TT CLASS="parameter" ><I >message</I ></TT > is appended to the file <TT CLASS="parameter" ><I >destination</I ></TT >. </TD ></TR ></TABLE ></DIV ></P ><P > <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><P ><B >Example 1. <B CLASS="function" >error_log()</B > examples</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" WIDTH="100%" ><TR ><TD ><PRE CLASS="programlisting" > 1 2 // Send notification through the server log if we can not 3 // connect to the database. 4 if (!Ora_Logon($username, $password)) { 5 error_log("Oracle database not available!", 0); 6 } 7 8 // Notify administrator by email if we run out of FOO 9 if (!($foo = allocate_new_foo()) { 10 error_log("Big trouble, we're all out of FOOs!", 1, 11 "operator@mydomain.com"); 12 } 13 14 // other ways of calling error_log(): 15 error_log("You messed up!", 2, "127.0.0.1:7000"); 16 error_log("You messed up!", 2, "loghost"); 17 error_log("You messed up!", 3, "/var/tmp/my-errors.log"); 18 </PRE ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE > </P ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="ref.info.html" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="manual.html" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.error-reporting.html" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >PHP options & information</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="ref.info.html" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >error_reporting</TD ></TR ></TABLE ></DIV ></BODY ></HTML >