Error_log () example

Source: Internet
Author: User

<?php
If you cannot connect to the database, send a notification to the server log
if (!Ora_logon($username,$password)) {
Error_log("Oracle Database Not available!",0);
}

Notify the administrator by email if FOO is exhausted
if (! ($foo=Allocate_new_foo())) {
Error_log("Big trouble, we ' re all out of foos!" , 1,
"[email protected]");
}

Another way to call Error_log ():
Error_log("You messed up!" , 3, "/var/tmp/my-errors.log");
?>

Error_log () is a function that sends an error message to a place, which is more common in programming, especially during the debugging phase of a program.

bool error_log ( string $message [, int $message _type = 0 [, string $destination [, string $extra _headers]] ) 

Send the error message to the Web server's error log, or to a file.

message

The error message that should be logged.信息长度限制:The default seem to be 1024 but can be changed by adjusting the value of the runtime configuration value of ‘log_errors_max_len‘

message_type

Set where the error should be sent. There are several possible types of information:

error_log () log type
0 messageThe system log sent to PHP, using the operating system's logging mechanism or a file, depends on what the error_log Directive sets. This is a default option.
1 messagedestinationthe e-mail address to send to the parameter settings. The fourth parameter extra_headers is only used in this type.
2 is no longer an option.
3 messageis sent to a destination file in the location. Characters message are not treated by default as a new line.
4 messageSent directly to the SAPI log handler.
destination

Goal. Its meaning is described above, as determined by the message_type parameters.

extra_headers

Extra head. message_typeused when set to 1 . This information type uses the same built-in function for mail ().

Error_log () example

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.