OpenersNotesSection(Spacer1)Details

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 (NonWLLink[WSActivate(), paclet:ref/c/WSActivate]) or WSConnect().

WSLogStreamToFile() returns 0 on failure and a nonzero value on success.

WSLogStreamToFile() is declared in the WSTP header file (RefLink[wstp.h, paclet:ref/file/wstp.h]).

OpenersPrimaryExamplesSection(Spacer1)Examples  (1)

OpenersExampleSection0(Spacer1)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 */ }

	WSActivate(link);

	/* ... */

	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);

	/* ... */

	WSClose(link);
	WSDeinitialize(env);
}

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(NonWLLink[WSStopLoggingStream(), paclet:ref/c/WSStopLoggingStream])  ▪  (NonWLLink[WSStopLoggingStreamToFile(), paclet:ref/c/WSStopLoggingStreamToFile])  ▪  (NonWLLink[WSDisableLoggingStream(), paclet:ref/c/WSDisableLoggingStream])  ▪  (NonWLLink[WSEnableLoggingStream(), paclet:ref/c/WSEnableLoggingStream])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[WSTP C API Developer Guide (Mac OS X), paclet:tutorial/WSTPDeveloperGuide-MacintoshOverview])}, {▪(RefLinkPlain[WSTP C API Developer Guide (Unix and Linux), paclet:tutorial/WSTPDeveloperGuide-UnixOverview])}, {▪(RefLinkPlain[WSTP C API Developer Guide (Windows), paclet:tutorial/WSTPDeveloperGuide-WindowsOverview])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Alphabetical Listing of WSTP C Functions, paclet:guide/AlphabeticalListingOfWSTPCFunctions])}, {▪(RefLinkPlain[WSTP C Functions for Exchanging Lists, paclet:guide/WSTPCFunctionsForExchangingLists])}})}})