FTP Logging Options <log>

Overview

The <system.ftpServer/log> element specifies the global log settings for the FTP service. More specifically, the attributes on the <system.ftpServer/log> element specify the following options:

  • centralLogFileMode - This attribute specifies whether the FTP service should use central logging (per-server) or site logging (per site).
    • If you specify central logging, a single log file will be kept for all of your FTP sites.
    • If you specify site logging, each FTP site will write to individual log files.
  • logInUTF8 - This attribute specifies that log files should be encoded in UTF8 format.

When you specify central logging, you can use the <centralLogFile> child element to configure the options for central log file.

Compatibility

Version Notes
IIS 7.5 The <log> element of the <system.ftpServer> element ships as a feature of IIS 7.5.
IIS 7.0 The <log> element of the <system.ftpServer> element was introduced in FTP 7.0, which was a separate download for IIS 7.0.
IIS 6.0 The <system.ftpServer> element and its child elements replace the IIS 6.0 FTP settings that were located in the LM/MSFTPSVC metabase path.

Note: The FTP 7.0 and FTP 7.5 services shipped out-of-band for IIS 7.0, which required downloading and installing the modules from the following URL:

http://www.iis.net/expand/FTP

With Windows 7 and Windows Server 2008 R2, the FTP 7.5 service ships as a feature for IIS 7.5, so downloading the FTP service is no longer necessary.

Setup

To support FTP publishing for your Web server, you must install the FTP service. To do so, use the following steps.

IIS 7.5 for Windows Server 2008 R2

  1. On the taskbar, click Start, point to Administrative Tools, and then click Server Manager.
  2. In the Server Manager hierarchy pane, expand Roles, and then click Web Server (IIS).
  3. In the Web Server (IIS) pane, scroll to the Role Services section, and then click Add Role Services.
  4. On the Select Role Services page of the Add Role Services Wizard, expand FTP Server.
  5. Select FTP Service.

    Note: To support ASP.Membership authentication or IIS Manager authentication for the FTP service, you will also need to select FTP Extensibility.
  6. Click Next.
  7. On the Confirm Installation Selections page, click Install.
  8. On the Results page, click Close.

IIS 7.5 for Windows 7

  1. On the taskbar, click Start, and then click Control Panel.
  2. In Control Panel, click Programs and Features, and then click Turn Windows Features on or off.
  3. Expand Internet Information Services, and then FTP Server.
  4. Select FTP Service.

    Note: To support ASP.Membership authentication or IIS Manager authentication for the FTP service, you will also need to select FTP Extensibility.
  5. Click OK.

IIS 7.0 for Windows Server 2008 and Windows Vista

  1. Download the installation package from the following URL:
  2. Follow the instructions in the following walkthrough to install the FTP service:

How To

How to configure site-level or server-level logging for the FTP service

  1. Open Internet Information Services (IIS) Manager:
    • If you are using Windows Server 2008 or Windows Server 2008 R2:
      • On the taskbar, click Start, point to Administrative Tools, and then click Internet Information Services (IIS) Manager.
    • If you are using Windows Vista or Windows 7:
      • On the taskbar, click Start, and then click Control Panel.
      • Double-click Administrative Tools, and then double-click Internet Information Services (IIS) Manager.
  2. In the Connections pane, click the server name.
  3. In the Home pane, double-click the FTP Logging feature.
  4. In the One log file per drop-down list, choose one of the following options:
    • Choose Site to specify that each FTP site will write to individual log files.
    • Choose Server to specify a single log file for all of your FTP sites.
  5. In the Actions pane, click Apply.

Configuration

The <system.ftpServer/log> element is configured at the global level in ApplicationHost.config.

Attributes

Attribute Description
centralLogFileMode Optional enum attribute.

Specifies whether the FTP service should use central logging (per-server) or site logging (per-site).
Attribute Description
Site Specifies that each FTP site will write to individual log files.

The numeric value is 0.
Central Specifies that a single log file will be kept for all of your FTP sites.

The numeric value is 1.
The default value is Site.
logInUTF8

Optional Boolean attribute.

Specifies whether IIS should log all strings for the FTP server in UCS Transformation Format 8 (UTF-8). This setting applies to text-mode logging for all of the sites on the FTP server.

The default value is true.

Child Elements

Element Description
centralLogFile Optional element.

Specifies the settings for the central log file.

Note: An unused element named <customLogging> was declared in the FTP 7.0 schema, but this was removed from the FTP 7.5 schema and should not be used.

Configuration Sample

The following configuration example enables central file logging for the FTP service.

<system.ftpServer>
   <log centralLogFileMode="Central">
      <centralLogFile enabled="true" />
   </log>
</system.ftpServer>

Sample Code

The following examples enable central file logging for the FTP service.

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

Note: You must be sure to set the commit parameter to apphost when you use AppCmd.exe to configure these settings. This commits the configuration settings to the appropriate location section in the ApplicationHost.config file.

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()
Deprecated Elements