ClearBox Server™ v1.2 Developer's Guide

ILivingstonAccounting::SetLoggingOptions

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

HRESULT SetLoggingOptions(
	[in] BSTR fileName,
	[in] BSTR fileNameExtension,
	[in] ROLLOVERMODE rllvrMode);

Parameters

fileName
[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 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.
fileNameExtension
[in] Extension that is added to the file name specified by fileName. If the value of fileNameExtension is NULL, logfile has no extension.
rllvrMode
[in] This parameter defines how often new logfile is created automatically by the server. rllvr defines the suffix that is added to a new logfile:

rllvrMode Suffix mask
RM_NONE No suffix is used
RM_HOURLY yyyyMMddHH
RM_ONSIZE yyyyMMddHH
RM_DAILY yyyyMMdd
RM_WEEKLY yyyyMMdd
RM_MONTHLY yyyyMM

All possible values of letters used in suffix are described here. Server extension should choose rollover mode depending on estimated accounting data amount.

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 and fileNameExtension parameters.

Remarks

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_20030330.txt, for example, and the next file name is c:\Logs\MyLog_20030331.txt after 24 hours will elapse.

ILivingstonAccounting* pAcc=NULL;
m_pServer->QueryInterface(IID_ILivingstonAccounting,(void**)&pAcc;
//QueryInterface will always succeed

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

pAcc->SetLoggingOptionsEx(fName,fExt,RM_DAILY);

SysFreeString(fName);
SysFreeString(fExt);
// Call to  pAcc->Release() is not necessary 

See Also

ILivingstonAccounting, Server services, SetLoggingOptionsEx, LogPacket


© 2001-2003 XPerience Technologies. www.xperiencetech.com

Created by chm2web html help conversion utility.