监控503错误的好用方法
分享一例php代码,用于监控日志中的500、503错误,并发送提示邮件,有需要的朋友参考下吧。也可以直接使用iis7服务器监控工具开启503错误监控: 本例代码,基于phpmailer类实现,设置个计划任务执行,自己设置要监控的错误代码。 可用于排查服务器问题,检测iis默认日志、nginx日志等,请根据自己的需要做修改。 有关phpmailer类的用法,请参考文章: 例子: 复制代码 代码示例: <?php /** * 监控日志 500 503错误 * by www.jbxue.com */ include("PHPMailer/class.phpmailer.php"); //error_reporting(0); $mail = new PHPMailer(); $mail->IsSMTP(); // telling the class to use SMTP $mail->SMTPDebug = 1; // enables SMTP debug information (for testing) // 1 = errors and messages // 2 = messages only $mail->SMTPAuth = true; // enable SMTP authentication $mail->Host = "smtp.126.com"; // sets