php error_log奇怪

时间:2013-03-14 13:32:55

标签: php error-handling

我的smart404.php代码中有一个全局变量debug_smart404:

$debug_smart404 = intval(get_option('debug_smart404' ));
    error_log("smart404_redirect: debug_smart404 =" . ( $debug_smart404 ) );

我使用了很多地方:

if ( $debug_smart404 > 4 ) # lotsa debug!
{
    error_log("smart404_redirect: take_1st_match=" . ( $take_1st_match  ? "yes" : "no" ) );
    error_log("smart404_redirect: take_exact_match=" . ( $take_exact_match ? "yes" : "no" ) );
    error_log("smart404_redirect: search_whole_uri=" . ( $search_whole_uri ? "yes" : "no" ) );
    error_log("smart404_redirect: walk_uri=" . ( $walk_uri ? "yes" : "no" ) );
    error_log("smart404_redirect: ignored_patterns_input=" . $patterns );
    error_log("smart404_redirect: ignored_patterns_array=" . join($patterns_array,",") );
            error_log("smart404_redirect: search_groups=" . join($search_groups,","));
}
while ( TRUE )
{
    error_log("smart404_redirect:inside while: debug_smart404 =" . ( $debug_smart404 ) );
...
    if ( $debug_smart404 > 3 ) # less debug
    {
        error_log("smart404_redirect: search_words=" . $search_words);
        }
...
        if ( $debug_smart404 > 0 ) {
            error_log("smart404_redirect: uri=" . $uri . "= #matches=" . $mct);
        } 
...
} #end while...

所以当我设置debug_smart404 == 5时,我得到了while之外的实例的预期输出:

[Thu Mar 14 08:32:42 2013] [error] [client xx.xx.xx.xx] smart404_redirect: debug_smart404 =5
[Thu Mar 14 08:32:42 2013] [error] [client xx.xx.xx.xx] smart404_redirect: take_1st_match=yes
[Thu Mar 14 08:32:42 2013] [error] [client xx.xx.xx.xx] smart404_redirect: take_exact_match=yes
[Thu Mar 14 08:32:42 2013] [error] [client xx.xx.xx.xx] smart404_redirect: search_whole_uri=no
[Thu Mar 14 08:32:42 2013] [error] [client xx.xx.xx.xx] smart404_redirect: walk_uri=yes
[Thu Mar 14 08:32:42 2013] [error] [client xx.xx.xx.xx] smart404_redirect: ignored_patterns_input=wp-.*\r\n(ing|s|er|est)$\r\nprivate/.*
[Thu Mar 14 08:32:42 2013] [error] [client xx.xx.xx.xx] smart404_redirect: ignored_patterns_array=@wp-.*@i,@(ing|s|er|est)$@i,@private/.*@i,@/(trackback|feed|(comment-)?page-?[0-9]*)/?$@i,@\\.(html|php)$@i,@/?\\?.*@i
[Thu Mar 14 08:32:42 2013] [error] [client xx.xx.xx.xx] smart404_redirect: search_groups=pages,posts,categories
[Thu Mar 14 08:32:42 2013] [error] [client xx.xx.xx.xx] smart404_redirect:inside while: debug_smart404 =5

但请注意,while循环的if语句中的error_log输出丢失了......但只在我的生产服务器上(netsol vps)

它在我的测试服务器上工作正常(lighttpd):

2013-03-14 08:26:40: (mod_fastcgi.c.2711) FastCGI-stderr: smart404_redirect: debug_smart404 =5
smart404_redirect: take_1st_match=no
smart404_redirect: take_exact_match=no
smart404_redirect: search_whole_uri=yes
smart404_redirect: walk_uri=yes
smart404_redirect: ignored_patterns_input=wp-.*
(ing|s|er|est)$
private/.*
smart404_redirect: ignored_patterns_array=@wp-.*@i,@(ing|s|er|est)$@i,@private/.*@i,@/(trackback|feed|(comment-)?page-?[0-9]*)/?$@i,@\.(html|php)$@i,@/?\?.*@i
smart404_redirect: search_groups=pages,posts,categories
smart404_redirect:inside while: debug_smart404 =5
smart404_redirect: search_words=cavitronix.com  xxx zzzxxxx
smart404_redirect: uri=/cavitronix.com//xxx/zzzxxxx= #matches=0

WTF ???在两者上运行php5,它曾经用于vps(debug = 1输出) - :

[Thu Mar 14 06:32:55 2013] [error] [client xx.xx.xx.xx] smart404_redirect: uri=/how-it-works= #matches=1
[Thu Mar 14 06:41:32 2013] [error] [client xx.xx.xx.xx] smart404_redirect: uri=/videos/e2c-overview/private/awstats/current/new.html= #matches=10
[Thu Mar 14 06:53:38 2013] [error] [client xx.xx.xx.xx] smart404_redirect: uri=/current/previous.html= #matches=3
[Thu Mar 14 06:54:47 2013] [error] [client xx.xx.xx.xx] smart404_redirect: uri=/press-releases= #matches=3

或者这是netsol的vps hackery的一些功能吗?

1 个答案:

答案 0 :(得分:0)

打印时的错误日志;您自己从生产服务器粘贴的错误日志将其显示为“inside while:debug_smart404 = 5”

你错过了很多代码背后的'......'。您的代码是否可能进入while循环,但是(在生产时)可能会快速中断/或继续,直到它到达其他错误日志语句。你可以积极地排除这种情况吗?