dooo61733 2013-01-18 09:30
浏览 30
已采纳

error_log无法按预期工作

I have the following basic code:

<?php

    //http://localhost/error_log.php
    echo "write to the error_log";
    error_log("error_log entry");
    //error_log("error_log entry",0);

?>

When I navigate to this page, I see write to the error_log in the browser. It even appears in the access_log /var/log/apache2/access.log.

[my ip here] - - [18/Jan/2013:09:18:54 +0000] "GET /error_log.php HTTP/1.1" 200 314 "-" "Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 Safari/537.11"

but when I check the error_log i.e. /var/log/apache2/error.log, I don't see either of the error_log messages.

Why are these not getting entered into the error_log?

  • 写回答

2条回答 默认 最新

  • dtkz3186 2013-01-18 09:38
    关注

    You call it without a second parameter, this means default is 0

    0   message is sent to PHP's system logger, using the Operating System's system logging mechanism or a file, depending on what the error_log configuration directive is set to. This is the default option.
    

    Now it depends on the configuration of error_log.

    If here is not "stderr", php will not log into the apache error log.

    It seams to be "syslog" of this php send your log message to the syslog.

    Now it depends on how you rsyslog.d is configurated.

    But have look at folling logs

    tail /var/log/syslog
    tail /var/log/messages
    tail /var/log/php
    tail /var/log/php.log
    

    You message should be in one of them.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗