ClearBox Server™ v1.2 Developer's Guide


Server extension should call this method or SetLoggingOptions to set logging options before using LogPacket method. This method allows to specify all possible logging parameters, while SetLoggingOptions provides only basic set of them,using default values for other.

HRESULT SetLoggingOptionsEx(
	[in] BSTR fileName,
	[in] BSTR fileNameExtension,
	[in] ROLLOVERMODE rllvrMode,
	[in] VARIANT_BOOL logInterim,
	[in] VARIANT_BOOL autoFlush,
	[in] unsigned long idleTime,
	[in] BSTR namePattern,
	[in] unsigned long maxFileSize);


[in] File name where accounting information will be logged. Note, that this parameter defines file name and path without file extension, and a suffix is added to the end of file name. This suffix depends on rllvrMode or namePattern parameter. This parameter can't be NULL. If the file name is prefixed by .\ then it's created in the same folder with the sever executable.
[in] Extension that is added to the file name specified by fileName. If the value of fileNameExtension is NULL, logfile has no extension.
[in] This parameter defines how often new logfile is created automatically by the server. Unless it is not specified explicitly in namePattern parameter, rllvr defines the suffix that is added to a new logfile:

rllvrMode Suffix mask
RM_NONE No suffix is used

All possible values of letters used in suffix are described here. Server extension should choose rollover mode depending on estimated accounting data amount.
[in] Defines whether the server should log accounting data with the attribute Acct-Status-Type=Interim (VARIANT_TRUE) or not (VARIANT_FALSE). Default value is VARIANT_TRUE, used if SetLoggingOptions is called instead of SetLoggingOptionsEx.
[in] Defines whether server will flush file buffers immediately after calls to LogPacket or LogPacketEx (VARIANT_TRUE) or not (VARIANT_FALSE). Turning flushing on may decrease the performance slightly but prevents possible loss of data. Default value is VARIANT_FALSE, used if SetLoggingOptions is called instead of SetLoggingOptionsEx.
[in] Reserved for future use and is ignored in ClearBox v1.2.
[in] Defines the suffix that is appended to the logfile name specified by fileName parameter. If namePattern is NULL, the suffix is defined by rllvrMode parameter. If namePattern is a valid string, it overrides the prefix defined by rllvrMode.
Besides special characters substituted by date and time values (full list of possible characters can be found here), this string may contain any other characters that are allowed in file names.
[in] Specifies the maximum size (in bytes) logfile may have. This parameter is used when rllvrMode is RM_ONSIZE. After logfile size exceeds this limit, new file is created automatically. Default value is 5242880 bytes, used if SetLoggingOptions is called instead of SetLoggingOptionsEx.

Return Values

This method may return E_INVALIDARG if fileName is NULL.

Thread Safety

This method can be called from any thread.

Memory Management

Server extension should allocate and free memory for fileName, fileNameExtension and namePattern parameters.


This method may be called not only before the first call to LogPacket. Calling this method doesn't affect existing logfile. It's common case to use it from ICommonExtender::InitializeEx.

Example Code

This code uses m_pServer as IServer interface pointer stored in ICommonExtenderEx::InitializeEx implementation. It makes server logging accounting data into the file c:\Logs\MyLog_2003_03_30.txt, for example, and the next file name is c:\Logs\MyLog_2003_03_31.txt after 24 hours will elapse.

ILivingstonAccounting* pAcc=NULL;
//QueryInterface will always succeed

BSTR fName=SysAllocString(L"c:\\Logs\\Mylog_");
BSTR fExt=SysAllocString(L"txt");
BSTR nPattern=SysAllocString(L"yyyy_MM_dd");


// Call to  pAcc->Release() is not necessary 

See Also

ILivingstonAccounting, Server services, SetLoggingOptions, LogPacket

© 2001-2003 XPerience Technologies.

Created by chm2web html help conversion utility.