CNntpClient::EnableTrace Method  
 
BOOL EnableTrace(
  LPCTSTR lpszTraceFile,  
  DWORD dwTraceFlags  
);

The EnableTrace method enables the logging of socket function calls to a file.

Parameters

lpszTraceFile
A pointer to a string which specifies the name of the trace log file. If this parameter is NULL or an empty string, the default file name cstrace.log is used. The file is stored in the directory specified by the TEMP environment variable, if it is defined; otherwise, the current working directory is used.
dwTraceFlags
An unsigned integer that specifies one or more options. This parameter is constructed by using a bitwise operator with any of the following values:
Value Description
TRACE_INFO All function calls are written to the trace file. This is the default value.
TRACE_ERROR Only those function calls which fail are recorded in the trace file.
TRACE_WARNING Only those function calls which fail or return values which indicate a warning are recorded in the trace file.
TRACE_HEXDUMP All functions calls are written to the trace file, plus all the data that is sent or received is displayed, in both ASCII and hexadecimal format.
TRACE_PROCESS All function calls in the current process are logged, rather than only those functions in the current thread. This option is useful for multithreaded applications that are using worker threads.

Return Value

If the method succeeds, the return value is non-zero. A return value of zero indicates an error. Failure typically indicates that the tracing library cstrcv11.dll cannot be loaded on the local system.

Remarks

When trace logging is enabled, the file is opened, appended to and closed for each socket function call. This makes it possible for an application to append its own logging information, however care should be taken to ensure that the file is closed before the next network operation is performed. To limit the size of the log files, enable and disable logging only around those sections of code that you wish to trace.

Note that the TRACE_HEXDUMP trace level generates very large log files since it includes all of the data exchanged between your application and the server.

Trace method logging is managed on a per-thread basis, not for each client handle. This means that all SocketTools libraries and components share the same settings in the current thread. If you are using multiple SocketTools libraries or components in your application, you only need to enable logging once.

Requirements

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

See Also

DisableTrace