CFtpServer::SetLogFile Method  
 
BOOL SetLogFile(
  UINT nLogFormat,  
  UINT nLogLevel,  
  LPCTSTR lpszFileName  
);

Change the current log format, level of detail and file name.

Parameters

nLogFormat
An integer value that specifies the format used when creating or updating the server log file. The following formats are supported:
Constant Description
FTP_LOGFILE_NONE
(0)
This value specifies that the server should not create or update a log file.
FTP_LOGFILE_COMMON
(1)
This value specifies that the log file should use the common log format that records a subset of information in a fixed format. This log format usually only provides information about file transfers.
FTP_LOGFILE_EXTENDED
(2)
This value specifies that the log file should use the standard W3C extended log file format. This is an extensible format that can provide additional information about the client session.
nLogLevel
An integer value that specifies the level of detail that should generated in the log file. The minimum value is 1 and the maximum value is 10. If this parameter is zero, it is the same as specifying a log file format of FTP_LOGFILE_NONE and will disable logging by the server.
lpszFileName
A pointer to a string that specifies the name of the log file that should be created or appended to. If the server was configured with logging enabled and this parameter is NULL or an empty string, the current log file name will not be changed. If the log file does not exist, it will be created. If it does exist, the contents of the log file will be appended to.

Return Value

If the method succeeds, the return value is non-zero. If the one of the parameters are invalid, the method will return zero.

Remarks

The SetLogFile method can be used to change the current log file name, the format of the log file or the level of detail recorded in the log file. In some situations it may be desirable to delete the current log file contents when changing the format or ensure that a new log file is created. To do this, combine the nLogFormat parameter with the constant FTP_LOGFILE_DELETE.

The higher the value of the nLogLevel parameter, the greater the level of detail that is recorded by the server. A log level of 1 instructs the server to only record file transfers, while a level of 10 instructs the server to record all commands processed by the server. Because a higher level of logging detail can negatively impact the performance of the server, it is recommended that you do not exceed a level of 5 for most applications. A log level of 10 should only be used for debugging purposes.

Example

UINT nLogFormat = FTP_LOGFILE_NONE;
UINT nLogLevel = 0;
UINT nNewLevel = 5;
BOOL bChanged = FALSE;

// Change the level of detail for the current log file if logging
// has been enabled and the current level is a lower value

if (pFtpServer->GetLogFile(&nLogFormat, &nLogLevel, NULL, 0))
{
    if (nLogFormat != FTP_LOGFILE_NONE && nLogLevel < nNewLevel)
        bChanged = pFtpServer->SetLogFile(nLogFormat, nNewLevel, NULL);
}

Requirements

Minimum Desktop Platform: Windows 7 (Service Pack 1)
Minimum Server Platform: Windows Server 2008 R2 (Service Pack 1)
Header File: cstools10.h
Import Library: csftsv10.lib
Unicode: Implemented as Unicode and ANSI versions.

See Also

GetLogFile, RenameServerLogFile