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 MLLogStreamToFile() again with a different file name to log to another file.

Do not call MLLogStreamToFile() prior to calling (NonWLLink[MLActivate(), paclet:/ref/c/MLActivate]) or MLConnect().

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

MLLogStreamToFile() is declared in the MathLink header file (RefLink[mathlink.h, paclet:/ref/file/mathlink.h]).

OpenersPrimaryExamplesSection(Spacer1)Examples  (1)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

#include "mathlink.h"

int main(int argc, char **argv)
{
	MLENV env;
	MLINK link;
	int error;
	int apiResult;
	const char *fileName;

	env = MLInitialize((MLEnvironmentParameter)0);
	if(env == (MLENV)0)
	{ /* Unable to create MathLink environment object */ }

	link = MLOpenArgcArgv(env, argc, argv, &error);
	if(link == (MLINK)0 || error != MLEOK)
	{ /* Unable to create link object */ }

	MLActivate(link);

	/* ... */

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

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

	MLReleaseLogFileNameForLink(link, fileName);

	/* ... */

	MLClose(link);
	MLDeinitialize(env);
}

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(NonWLLink[MLStopLoggingStream(), paclet:/ref/c/MLStopLoggingStream])  ▪  (NonWLLink[MLStopLoggingStreamToFile(), paclet:/ref/c/MLStopLoggingStreamToFile])  ▪  (NonWLLink[MLDisableLoggingStream(), paclet:/ref/c/MLDisableLoggingStream])  ▪  (NonWLLink[MLEnableLoggingStream(), paclet:/ref/c/MLEnableLoggingStream])}})}})