2012-06-13 18 views

回答

-3
ErrorLog "|bin/rotatelogs /var/logs/errorlog.%Y-%m-%d-%H_%M_%S 5M" 

此配置將旋轉每當其達到尺寸5兆字節的錯誤日誌文件,並且後綴到日誌文件名稱將形式errorlog.YYYY-MM-DD-HH_MM_SS的創建。

對於從apache.org Link Here

+7

-1我不知道爲什麼這是一個被接受的答案。這不會做任何事情來阻止日誌中單個條目的截斷。 –

+0

這實際上會截斷長日誌,因爲它受限於OS的管道長度限制。 –

0

閱讀上面的問題使我想知道如果這個問題是內阿帕奇。 是的,截斷髮生在Apache的PHP內部將允許甚至超過10,000個字符。這裏有一個Perl腳本評估Apache的發佈很長的錯誤信息到日誌的能力:

#!/usr/bin/perl -w 
# 
# Test error log length limitations 
# Result: no limitation 
# 
# 

use strict; 
use CGI; 


my $query = CGI->new; 
print $query->header; 

print "<html><body>You have reached " 
    ."cgi-bin/admin/test_error_log.pl" 
    ."</body></html>\n"; 
print STDERR "This is an error message from $0\n"; 
print STDERR " 
[Above should be a blank line] here is a multiline error message 
here is the third and final line of it\n"; 
print STDERR 'abcde' x 200; #1,000 characters 
print STDERR "\nAbove is 1,000 characters of output of 'abcde'\n"; 
print STDERR 'vwxyz' x 2000; #10,000 characters 
print STDERR "\nAbove is 10,000 characters of output of 'vwxyz'\n"; 
+0

我有與Nginx相同的問題。 –

1

PHP Manual說,大約log_errors_max_len的php.ini設置:

設置log_errors的最大字節長度。 (...)默認值爲 1024,0不允許應用任何最大長度。

一些建議,你可以改變它這樣做,例如:

ini_set("log_errors_max_len", 2048); 

但手冊補充說:

這個長度適用於記錄的錯誤,顯示錯誤,也 $ php_errormsg,但不能顯式調用函數,如 error_log()

我正試圖找到解決方案。如果我這樣做會編輯。

3

由於波爾多said,設置log_errors_max_len似乎在這種情況下很沒用,和PHP手冊指出這分明。

唯一的解決辦法我能到目前爲止發現是使用:

error_log("Long error message...", 3, CUSTOM_LOG_FILE); 

error_log()第二個參數可以讓你的消息重定向到一個自定義文件。所以,最後一個參數應該是自定義日誌文件的路徑。

這樣我得到完整的錯誤信息,什麼可能是更重要的人,非ASCII字符在那裏清晰可讀(不知道雖然,可能是我的壞,但是當我用標準日誌文件 - 我得到的東西像\xd0\xbf)。