HttpResponse.AppendToLog(String) 方法


將自訂記錄資訊加入至網際網路資訊服務 (IIS) 記錄檔。Adds custom log information to the Internet Information Services (IIS) log file.

 void AppendToLog(System::String ^ param);
public void AppendToLog (string param);
member this.AppendToLog : string -> unit
Public Sub AppendToLog (param As String)



要加入至記錄檔的文字。The text to add to the log file.


下列範例顯示如何將字串附加至記錄檔。The following example shows how to append a string to the log.

Response.AppendToLog("Page delivered");
Response.AppendToLog("Page delivered")


若要允許在記錄檔中記錄指定的字串,您必須先針對您想要在 IIS 中記錄活動的網站,啟用 [擴充記錄屬性] 對話方塊的 [ URI 查詢] 選項。To allow for the specified string to be recorded in the log file, you first must enable the URI Query option of the Extended Logging Properties dialog box for the site that you want to log activity for in IIS.

若要在 IIS 6.0 中自訂擴充記錄,請遵循下列步驟:To customize extended logging in IIS 6.0, follow these steps:

  1. 在 [IIS 管理員] 中,依序展開 [本機電腦] 節點、[Web] 或 [FTP 網站] 資料夾、以滑鼠右鍵按一下 Web 或 FTP 網站,然後按一下 [ 內容]。In IIS Manager, expand the local computer node, expand the Web or FTP Sites folder, right-click the Web or FTP site, and then click Properties.

  2. 按一下 [ Web] 或 [FTP 網站] 索引標籤,然後選取 [啟用記錄] 核取方塊(如果尚未選取)。Click the Web or FTP Site tab, and then select the Enable logging check box (if it is not already selected).

  3. 在 [作用中記錄格式] 方塊中,按一下 [ W3C 擴充記錄檔格式]。In the Active log format box, click W3C Extended Log File Format.

  4. 按一下 [屬性]。Click Properties.

  5. 按一下 [ Advanced ] 索引標籤,選取您要記錄的屬性,然後按一下 [確定]Click the Advanced tab, select the properties that you want to log, and then click OK.