【问题标题】:PHP error_log output format differs for custom logPHP error_log 输出格式因自定义日志而异
【发布时间】:2020-05-17 12:40:48
【问题描述】:

PHP 7.2。当我使用时:

error_log('test');

在错误日志中我看到一个条目:

[31-Jan-2020 20:05:28 UTC] test

(注意行首的日期/时间)

当我使用时:

error_log('test',3, 'my_error_log');

我刚刚得到:

test

在“my_error_log”文件中 - 开头没有日期时间。甚至新行也不会自动添加。

为什么两个 error_log 调用会产生不同的输出?怎么控制?

【问题讨论】:

    标签: php format output error-log


    【解决方案1】:

    在第一种情况下,error_log 可能会输出到默认日志文件,其位置取决于服务器软件,该软件会在您的消息前面加上日期时间字符串。 error_log 不添加字符串。

    即使是新行也不会自动添加。

    根据 PHP 文档,当您选择 message_type 的值为 3 时,不会自动添加新行。 https://www.php.net/manual/en/function.error-log.php

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-09-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-02
      • 2011-09-13
      相关资源
      最近更新 更多