LOGGING_PARAMETERS Structure

IIS 7.0
 

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

struct LOGGING_PARAMETERS  
{  
   LPWSTR pszSessionId;  
   LPWSTR pszSiteName;  
   LPWSTR pszUserName;  
   LPWSTR pszHostName;  
   LPWSTR pszRemoteIpAddress;  
   unsigned long dwRemoteIpPort;  
   LPWSTR pszLocalIpAddress;  
   unsigned long dwLocalIpPort;  
   unsigned __int64 BytesSent;  
   unsigned __int64 BytesReceived;  
   LPWSTR pszCommand;  
   LPWSTR pszCommandParameters;  
   LPWSTR pszFullPath;  
   unsigned long dwElapsedMilliseconds;  
   unsigned long FtpStatus;  
   unsigned long FtpSubStatus;  
   HRESULT hrStatus;  
   LPWSTR pszInformation;  
};  

Member NameDefinition
BytesReceivedThe number of bytes received from the client.
BytesSentThe number of bytes sent to the client.
pszCommandThe FTP command.
pszCommandParametersThe parameters related to the FTP command.
dwElapsedMillisecondsThe number of milliseconds it took for the operation to complete.
FtpStatusThe FTP status of the current command.
FtpSubStatusThe FTP substatus of the current command.
pszFullPathThe full path of the operation for the FTP command.
pszHostNameThe FTP virtual host name.
hrStatusThe Windows error code for the operation.
pszInformationAdditional troubleshooting information for the command.
pszLocalIpAddressThe local IP address to which the client is connected.
dwLocalIpPortThe TCP/IP port of the server.
pszRemoteIpAddressThe IP address of the client.
dwRemoteIpPortThe TCP/IP port of the client.
pszSessionIdThe session ID.
pszSiteNameThe name of the server instance that is being logged.
pszUserNameThe name of the user.

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

public:  
   STDMETHOD(Log)(LOGGING_PARAMETERS * pLoggingParameters)  
   {  
      // Note: You would add your own custom logic here.  
      HRESULT hr = S_OK;  
      DWORD dwResult;  
      HANDLE hFile;  
      char szLogEntry[256]="";  
      const DWORD FILE_WRITE_TO_END_OF_FILE = 0xffffffff;  
  
      OVERLAPPED Overlapped = { 0 };  
      Overlapped.Offset = FILE_WRITE_TO_END_OF_FILE;  
      Overlapped.OffsetHigh = -1;  
  
      // Retrieve the current date and time for the log entry.  
      SYSTEMTIME CurrentTime;  
      GetSystemTime(&CurrentTime);  
  
      // Open the log file for output.  
      hFile = CreateFile(  
         L"\\\\?\\C:\\logfiles\\myftpsite\\myftplog.log",  
         GENERIC_WRITE,  
         FILE_SHARE_READ,  
         NULL,  
         OPEN_ALWAYS,  
         FILE_ATTRIBUTE_NORMAL | FILE_FLAG_WRITE_THROUGH,  
         NULL);  
  
      // Return an error if a failure occurs.  
      if (hFile == INVALID_HANDLE_VALUE)  
      {  
         hr = HRESULT_FROM_WIN32(GetLastError());  
         goto EXIT;  
      }  
  
      // Format the log entry.  
      hr = StringCchPrintfA(  
         szLogEntry,256,  
         "%04d-%02d-%02d\t%02d:%02d:%02d\t%S\t%d\r\n",  
         CurrentTime.wYear,CurrentTime.wMonth,CurrentTime.wDay,  
         CurrentTime.wHour,CurrentTime.wMinute,CurrentTime.wSecond,  
         pLoggingParameters->pszCommand,  
         pLoggingParameters->FtpStatus);  
  
      // Test for error.  
      if (FAILED(hr))  
      {  
         // Return the error if a failure occurs.  
         hr = HRESULT_FROM_WIN32(GetLastError());  
         goto EXIT;  
      }  
  
      // Write the log entry to the log file.  
      if(!WriteFile(hFile, szLogEntry,  
         strlen(szLogEntry), &dwResult, &Overlapped))        
      {  
         // Return an error if a failure occurs.  
         hr = HRESULT_FROM_WIN32(GetLastError());  
         goto EXIT;  
      }  
  
EXIT:  
      // Close the log file if it is open.  
      if(CloseHandle(hFile)==0)  
      {  
         // Return an error if a failure occurs.  
         hr = HRESULT_FROM_WIN32(GetLastError());  
      }  
      return hr;  
   }  

TypeDescription
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
Referenceftpext.tlb

IFtpLogProvider Interface

Show: