doujiao3072 2019-04-11 14:08
浏览 39

将trigger_error()输出路由到error_log并禁用“display_errors”

We want to log all output generated by trigger_error() function calls into an error_log file for later analysis. As our application has a single entry point for both HTTP based requests and console requests, this should ideally be setup within the same file as shown below, e.g. here named error.php

<?php
error_reporting( E_ALL );
ini_set("display_errors", 0);
ini_set("error_log", "test-error.log");
error_log("Msg 1");
trigger_error("Msg 2");

Calling error.php via the webserver results in correct logging in test-error.log:

[11-Apr-2019 16:02:50 Europe/City] Msg 1
[11-Apr-2019 16:02:50 Europe/City] PHP Notice:  Msg 2 in error.php on line 6

Calling error.php via the local shell results in not logging the trigger_error() call.

[11-Apr-2019 16:05:31 Europe/City] Msg 1

How should we set up error reporting to have php errors from trigger_error() also within the same log file?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 帮我写一个c++工程
    • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
    • ¥15 关于smbclient 库的使用
    • ¥15 微信小程序协议怎么写
    • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
    • ¥20 怎么用dlib库的算法识别小麦病虫害
    • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
    • ¥15 java写代码遇到问题,求帮助
    • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
    • ¥15 有了解d3和topogram.js库的吗?有偿请教