Click to Rate and Give Feedback
Collapse All/Expand All Collapse All
IIS 7.0: FtpLogEntry Class

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 IIS 7.0: IFtpLogProvider Interface (Managed).

C#
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;
}
Visual Basic
Public NotInheritable Class FtpLogEntry
   Public BytesReceived As Long
   Public BytesSent As Long
   Public Command As String
   Public CommandParameters As String
   Public ElapsedMilliseconds As Integer
   Public FtpStatus As Integer
   Public FtpSubStatus As Integer
   Public FullPath As String
   Public HostName As String
   Public HRStatus As Integer
   Public Information As String
   Public LocalIPAddress As String
   Public LocalIPPort As Integer
   Public RemoteIPAddress As String
   Public RemoteIPPort As Integer
   Public SessionId As String
   Public SiteName As String
   Public UserName As String
End Class

Member Name

Definition

BytesReceived

The number of bytes received from the client.

BytesSent

The number of bytes sent to the client.

Command

The FTP command.

CommandParameters

The parameters related to the FTP command.

ElapsedMilliseconds

The number of milliseconds it took for the operation to complete.

FtpStatus

The FTP status of the current command.

FtpSubStatus

The FTP sub-status of the current command.

FullPath

The full path of the operation for the FTP command.

HostName

The FTP virtual host name.

HRStatus

The Windows error code for the operation.

Information

Additional troubleshooting information for the command.

LocalIPAddress

The local IP address the client is connected to.

LocalIPPort

The TCP/IP port of the server.

RemoteIPAddress

The IP address of the client.

RemoteIPPort

The TCP/IP port of the client.

SessionId

The session ID.

SiteName

The name of the server instance that is being logged.

UserName

The 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,
      IFtpLogProvider
   {
      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.
            sw.WriteLine("{0}\t{1}\t{2}\t{3}\t{4}\t{5}",
               dt.ToShortDateString(),
               dt.ToLongTimeString(),
               loggingParameters.RemoteIPAddress,
                (un.Length == 0) ? "-" : un,
               loggingParameters.Command,
               loggingParameters.SessionId);
         }
      }
   }
}

Type

Description

Client

IIS 7.5

Server

IIS 7.5

Product

FTP 7.5

Reference

Microsoft.Web.FtpServer.dll

© 2010 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker