PHP Custom error log

Source: Internet
Author: User
Tags sprintf

<?php//Error handler function MyErrorHandler ($errno, $errstr, $errfile, $errline) {$log _file = "./php_%s_log_". Date ("YMD") .".    Log ";//define the file directory and file name $template = ';            Switch ($errno) {case E_user_error: $template. = "User error level errors, the error number must be fixed [$errno] $errstr";            $template. = "Error location file $errfile, line $errline \ n";            $log _file = sprintf ($log _file, ' error ');        Exit (1);//system exit break;            Case e_user_warning: $template. = "User WARNING level error, recommended fix error number [$errno] $errstr";            $template. = "Error location file $errfile, line $errline \ n";            $log _file = sprintf ($log _file, ' warning ');        Break            Case E_user_notice: $template. = "User NOTICE level error, does not affect the system, does not fix error number [$errno] $errstr";            $template. = "Error location file $errfile, line $errline \ n";            $log _file = sprintf ($log _file, ' notice ');        Break            Default: $template. = "Unknown error type: error number [$errno] $errstr"; $template. = "Error location file $errfile, section $erRline line \ n ";            $log _file = sprintf ($log _file, ' unknown ');    Break    } file_put_contents ($log _file, $template, file_append); return true;} $error _handler = Set_error_handler ("MyErrorHandler");//Turn on the custom error log echo $a;

PHP Custom error log

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.