FtpLogEntry Class

IIS 7.0

Defines the information for FTP activity, such as user name, session ID, IP addresses for the client and server, etc. Developers can select which logging information to use when implementing the IFtpLogProvider Interface.

public sealed class FtpLogEntry  
   public long BytesReceived;  
   public long BytesSent;  
   public string Command;  
   public string CommandParameters;  
   public int ElapsedMilliseconds;  
   public int FtpStatus;  
   public int FtpSubStatus;  
   public string FullPath;  
   public string HostName;  
   public int HRStatus;  
   public string Information;  
   public string LocalIPAddress;  
   public int LocalIPPort;  
   public string RemoteIPAddress;  
   public int RemoteIPPort;  
   public string SessionId;  
   public string SiteName;  
   public string UserName;  

Member NameDefinition
BytesReceivedThe number of bytes received from the client.
BytesSentThe number of bytes sent to the client.
CommandThe FTP command.
CommandParametersThe parameters related to the FTP command.
ElapsedMillisecondsThe number of milliseconds it took for the operation to complete.
FtpStatusThe FTP status of the current command.
FtpSubStatusThe FTP sub-status of the current command.
FullPathThe full path of the operation for the FTP command.
HostNameThe FTP virtual host name.
HRStatusThe Windows error code for the operation.
InformationAdditional troubleshooting information for the command.
LocalIPAddressThe local IP address the client is connected to.
LocalIPPortThe TCP/IP port of the server.
RemoteIPAddressThe IP address of the client.
RemoteIPPortThe TCP/IP port of the client.
SessionIdThe session ID.
SiteNameThe name of the server instance that is being logged.
UserNameThe name of the user.

The following code example illustrates using the IFtpLogProvider interface to create a custom logging module for the FTP service.

using System;  
using System.IO;  
using Microsoft.Web.FtpServer;  
namespace FtpLogging  
   public class FtpLogDemo : BaseProvider,  
      void IFtpLogProvider.Log(FtpLogEntry loggingParameters)  
         // Note: You would add your own custom logic here.  
         // Open the log file for output.  
         using (StreamWriter sw =  
            new StreamWriter(@"C:\logfiles\myftpsite\myftplog.log",true))  
            // Retrieve the current date and time for the log entry.  
            DateTime dt = DateTime.Now;  
            // Retrieve the user name.  
            string un = loggingParameters.UserName;  
            // Write the log entry to the log file.  
                (un.Length == 0) ? "-" : un,  

For an additional example, see How to Use Managed Code (C#) to Create a Simple FTP Logging Provider.

Client- IIS 7.5 on Windows 7
- IIS 8.0 on Windows 8
- IIS 10.0 on Windows 10
Server- IIS 7.5 on Windows Server 2008 R2
- IIS 8.0 on Windows Server 2012
- IIS 8.5 on Windows Server 2012 R2
- IIS 10.0 on Windows Server 2016 Technical Preview
Product- IIS 7.0, IIS 7.5, IIS 8.0, IIS 8.5, IIS 10.0

IFtpLogProvider Interface