FTP 中央記錄選項 < centralLogFile>
概觀
元素 <centralLogFile>
會指定中央記錄檔的設定,當您為 centralLogFileMode
專案的 屬性 <system.ftpServer/log>
指定centralLogFileMode時,會使用此設定。 當您指定集中記錄時,所有 FTP 月臺都會保留單一記錄檔。
相容性
版本 | 備註 |
---|---|
IIS 10.0 | 在 <centralLogFile> IIS 10.0 中未修改專案。 |
IIS 8.5 | 未 <centralLogFile> 在 IIS 8.5 中修改專案。 |
IIS 8.0 | 在 IIS 8.0 中未修改專案 <centralLogFile> 。 |
IIS 7.5 | 元素 <centralLogFile> 的 <log> 元素會隨附為 IIS 7.5 的功能。 |
IIS 7.0 | 元素 <centralLogFile> 的 <log> 元素是在 FTP 7.0 中引進,這是 IIS 7.0 的個別下載。 |
IIS 6.0 | 元素 <system.ftpServer> 及其子項目會取代位於 LM/MSFTPSVC 中繼基底路徑中的 IIS 6.0 FTP 設定。 |
使用 Windows 7 和 Windows Server 2008 R2 時,FTP 7.5 服務會隨附為 IIS 7.5 的功能,因此不再需要下載 FTP 服務。
安裝程式
若要支援 Web 服務器的 FTP 發佈,您必須安裝 FTP 服務。 若要這樣做,請使用下列步驟。
Windows Server 2012 或 Windows Server 2012 R2
在工作列上,按一下 [伺服器管理員]。
在伺服器管理員中,按一下 [管理]功能表,然後按一下 [新增角色和功能]。
在 [ 新增角色和功能 精靈] 中,按 [下一步]。 選取安裝類型,然後按 [ 下一步]。 選取目的地伺服器,然後按 [ 下一步]。
在 [ 伺服器角色] 頁面上,展開 [Web 服務器] ([IIS) ],然後選取 [ FTP 伺服器]。
按 [下一步],然後在 [ 選取功能 ] 頁面上,再次按 [ 下一步 ]。
在 [確認安裝選項] 頁面上,按一下 [安裝]。
在 [結果] 頁面上,按一下 [關閉]。
Windows 8 或Windows 8.1
在 [開始] 畫面上,將指標全部移至左下角,以滑鼠右鍵按一下 [開始] 按鈕,然後按一下[主控台]。
在主控台中,按一下 [程式和功能],然後按一下 [開啟或關閉 Windows 功能]。
展開 [Internet Information Services],然後選取 [FTP 伺服器]。
按一下 [確定]。
按一下 [關閉] 。
Windows Server 2008 R2
在工作列上,按一下 [開始],指向 [系統管理工具],然後按一下[伺服器管理員]。
在[伺服器管理員階層] 窗格中,展開 [角色],然後按一下 [Web 服務器] (IIS) 。
在 [Web 服務器 (IIS) ] 窗格中,捲動至 [ 角色服務 ] 區段,然後按一下 [ 新增角色服務]。
在 [新增角色服務精靈] 的 [選取角色服務] 頁面上,展開[FTP 伺服器]。
選取 [FTP 服務]。
按一下 [下一步] 。
在 [確認安裝選項] 頁面上,按一下 [安裝]。
在 [結果] 頁面上,按一下 [關閉]。
Windows 7
在工作列上,按一下 [開始],然後按一下[主控台]。
在主控台中,按一下 [程式和功能],然後按一下 [開啟或關閉 Windows 功能]。
展開 [Internet Information Services],然後展開 [FTP 伺服器]。
選取 [FTP 服務]。
按一下 [確定]。
Windows Server 2008 或 Windows Vista
從下列 URL 下載安裝套件:
請遵循下列逐步解說中的指示來安裝 FTP 服務:
作法
如何設定 FTP 服務的月臺層級或伺服器層級記錄
(IIS) 管理員開啟 Internet Information Services:
如果您使用 Windows Server 2012 或 Windows Server 2012 R2:
- 在工作列上,依序按一下 [伺服器管理員]、[工具],然後按一下 [Internet Information Services] ([IIS) 管理員]。
如果您使用 Windows 8 或 Windows 8.1:
- 按住Windows鍵,按字母X,然後按一下[主控台]。
- 按一下 [ 系統管理工具],然後按兩下 [Internet Information Services] ([IIS) 管理員]。
如果您使用 Windows Server 2008 或 Windows Server 2008 R2:
- 在工作列上,按一下 [ 開始],指向 [ 系統管理工具],然後按一下 [ Internet Information Services (IIS) 管理員]。
如果您使用 Windows Vista 或 Windows 7:
- 在工作列上,按一下 [開始],然後按一下[主控台]。
- 按兩下 [ 系統管理工具],然後按兩下 [Internet Information Services] ([IIS) 管理員]。
在 [ 連線 ] 窗格中,按一下伺服器名稱。
在 [每個記錄檔] 下拉式清單中,選擇下列其中一個選項:
在 [動作] 窗格中,按一下 [套用]。
組態
專案 <centralLogFile>
是在全域層級設定ApplicationHost.config。
屬性 | 描述 | ||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
directory |
選擇性字串屬性。 指定記錄目錄,其中會儲存記錄檔和記錄相關的支援檔案。 預設值是 %SystemDrive%\inetpub\logs\LogFiles 。 |
||||||||||||||||||||||||||||||||||||||||||||
enabled |
選擇性 Boolean 屬性。 如果已啟用記錄,則為true;否則為 false。 預設值是 true 。 |
||||||||||||||||||||||||||||||||||||||||||||
localTimeRollover |
選擇性 Boolean 屬性。 如果根據當地時間建立新的記錄檔,則為true;否則為false表示國際標準時間 (UTC) ,先前稱為 Greenwich Mean Time (GMT) 。 注意: 不論設定為何,每個 W3C 擴充記錄記錄記錄的時間戳記都是以 UTC 為基礎。 預設值是 false 。 |
||||||||||||||||||||||||||||||||||||||||||||
logExtFileFlags |
選擇性旗標屬性。 指定當您在網站記錄事件期間使用 W3C 擴充記錄檔格式) 或 ODBC 資料來源時,寫入記錄檔 (的資訊類別。 logExtFileFlags屬性可以是下列一或多個值。 如果您指定多個值,請使用逗號分隔 (,) 。 預設值為 Date 、 Time 、 ServerIP Method UriStem UserName ClientIP 、 FtpStatus 、、 FtpSubStatus ServerPort Win32Status Session 、 和 。 FullPath
|
||||||||||||||||||||||||||||||||||||||||||||
period |
選擇性列舉屬性。 指定 FTP 服務建立新記錄檔的頻率。 屬性 period 可以是下列其中一個可能的值。預設值是 Daily 。
|
||||||||||||||||||||||||||||||||||||||||||||
selectiveLogging |
選擇性旗標屬性。 指定 FTP 記錄的詳細資訊。 預設值是 LogSuccessful,LogError,LogInfrastructure 。
|
||||||||||||||||||||||||||||||||||||||||||||
truncateSize |
選擇性 int64 屬性。 指定記錄檔的大小上限, (位元組) 之後建立新的記錄檔。 只有在為 period 屬性選擇時 MaxSize ,才適用這個值。 檔案大小下限為 1,048,576 個位元組。 如果此屬性設定為小於 1,048,576 個位元組的值,則預設值會隱含假設為 1,048,576 個位元組。預設值是 20971520 。 |
子元素
無。
組態範例
下列組態範例會啟用 FTP 服務的中央檔案記錄。
<system.ftpServer>
<log centralLogFileMode="Central">
<centralLogFile enabled="true" />
</log>
</system.ftpServer>
範例程式碼
下列範例會啟用 FTP 服務的中央檔案記錄。
AppCmd.exe
appcmd.exe set config -section:system.ftpServer/log /centralLogFileMode:"Central" /commit:apphost
appcmd.exe set config -section:system.ftpServer/log /centralLogFile.enabled:"True" /commit:apphost
注意
當您使用 AppCmd.exe 來設定這些設定時,請務必將 認可 參數 apphost
設定為 。 這會將組態設定認可至ApplicationHost.config檔案中的適當位置區段。
C#
using System;
using System.Text;
using Microsoft.Web.Administration;
internal static class Sample
{
private static void Main()
{
using (ServerManager serverManager = new ServerManager())
{
Configuration config = serverManager.GetApplicationHostConfiguration();
ConfigurationSection logSection = config.GetSection("system.ftpServer/log");
logSection["centralLogFileMode"] = @"Central";
ConfigurationElement centralLogFileElement = logSection.GetChildElement("centralLogFile");
centralLogFileElement["enabled"] = true;
serverManager.CommitChanges();
}
}
}
VB.NET
Imports System
Imports System.Text
Imports Microsoft.Web.Administration
Module Sample
Sub Main()
Dim serverManager As ServerManager = New ServerManager
Dim config As Configuration = serverManager.GetApplicationHostConfiguration
Dim logSection As ConfigurationSection = config.GetSection("system.ftpServer/log")
logSection("centralLogFileMode") = "Central"
Dim centralLogFileElement As ConfigurationElement = logSection.GetChildElement("centralLogFile")
centralLogFileElement("enabled") = True
serverManager.CommitChanges()
End Sub
End Module
JavaScript
var adminManager = new ActiveXObject('Microsoft.ApplicationHost.WritableAdminManager');
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST";
var logSection = adminManager.GetAdminSection("system.ftpServer/log", "MACHINE/WEBROOT/APPHOST");
logSection.Properties.Item("centralLogFileMode").Value = "Central";
var centralLogFileElement = logSection.ChildElements.Item("centralLogFile");
centralLogFileElement.Properties.Item("enabled").Value = true;
adminManager.CommitChanges();
VBScript
Set adminManager = createObject("Microsoft.ApplicationHost.WritableAdminManager")
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST"
Set logSection = adminManager.GetAdminSection("system.ftpServer/log", "MACHINE/WEBROOT/APPHOST")
logSection.Properties.Item("centralLogFileMode").Value = "Central"
Set centralLogFileElement = logSection.ChildElements.Item("centralLogFile")
centralLogFileElement.Properties.Item("enabled").Value = True
adminManager.CommitChanges()