WSLogStreamToFile (C Function)

int WSLLogStreamToFile ( WSLINK l , const char * f )

turns on logging of the WSTP connection specified by l and logs the contents of the stream to the file specified in f.


  • The user must have permission to write to the file specified in f.
  • You can send the log of the same stream to more than one file. Call WSLogStreamToFile() again with a different file name to log to another file.
  • Do not call WSLogStreamToFile() prior to calling WSActivate() or WSConnect().
  • WSLogStreamToFile() returns 0 on failure and a nonzero value on success.
  • WSLogStreamToFile() is declared in the WSTP header file wstp.h.


Basic Examples  (1)

#include "wstp.h"

int main(int argc, char **argv)
    WSENV env;
    WSLINK link;
    int error;
    int apiResult;
    const char *fileName;

    env = WSInitialize((WSEnvironmentParameter)0);
    if(env == (WSENV)0)
    { /* Unable to create WSTP environment object */ }

    link = WSOpenArgcArgv(env, argc, argv, &error);
    if(link == (WSLINK)0 || error != WSEOK)
    { /* Unable to create link object */ }


    /* ... */

    apiResult = WSLogFileNameForLink(link, &fileName);
    if(! apiResult)
    { /* Unable to generate log file name */ }

    apiReuslt = WSLogStreamToFile(link, fileName);
    if(! apiResult)
    { /* Unable to log stream to file */ }

    WSReleaseLogFileNameForLink(link, fileName);

    /* ... */