2012-12-18 33 views
16

我想啓用重寫日誌來調試一些重寫規則給我的問題。所以我說這行我的httpd.conf文件的末尾:無法配置重寫日誌

我做
<IfModule mod_rewrite.c> 
    RewriteLog "/logs/rewrite.log" 
    RewriteLogLevel 4 
</IfModule> 

接下來的事情是重新啓動Apache。它會導致錯誤,但不會啓動。這是我得到的XAMPP控制面板中:

13:14:56 [Apache] Error: Apache shutdown unexpectedly. 
13:14:56 [Apache] This may be due to a blocked port, missing dependencies, 
13:14:56 [Apache] improper privileges, a crash, or a shutdown by another method. 
13:14:56 [Apache] Check the "/xampp/apache/logs/error.log" file 
13:14:56 [Apache] and the Windows Event Viewer for more clues 

我沒有得到任何線索error.log中雖然。事實上,發生此錯誤時不會生成任何行。

我也試圖改變RewriteLog線使用絕對路徑:

RewriteLog "c:\xampp\apache\logs\rewrite.log" 

你能幫幫我嗎?

回答

31

哪個版本的Apache?

在2.4中,RewriteLog *指令不再存在,因爲日誌記錄已被重寫。在這種情況下,您應該將mod_rewrite.c:trace3附加到您的LogLevel行,其中traceX是詳細程度級別(8> = X> = 1)。輸出將被寫入Apache標準錯誤日誌(ErrorLog)。

是否也能運行這些命令: httpd -t(語法檢查),然後httpd -w(運行Apache,但保持打開控制檯,作爲標準錯誤)

+1

是的,我的服務器是Apache的2.4。我已經看到了我的默認配置是'LogLevel的warn',所以我應該這樣做?:'LOGLEVEL警告mod_rewrite.c:trace3' –

+2

是:用'LOGLEVEL警告mod_rewrite.c:trace3'警告是默認的詳細級別爲所有模塊和你重新定義mod_rewrite的水平,以更高的價值 – julp

+0

完美!謝謝,它的工作原理!還有一個問題:除了Apache 2.4中的錯誤日誌之外,是否可以創建自己的重寫日誌? –