O'Reilly logo

COM & .NET Component Services by Juval Lowy

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How Does the Logbook Work?

The logbook uses COM+ events to pass the information collected from the application to the logbook components. The components (the HTML and XML versions) implement the ILogbook interface (see Figure A-3), a custom interface with methods corresponding to what is being logged—method call, event, or error. The ILogbook interface is defined as:

interface ILogbook : IUnknown
{
  typedef struct tagLOG_ENTRY
  {   
    HRESULT  hres;
    DWORD    dwErrorCode;
    DWORD    dwProcessID;
    DWORD    dwThreadID;
    GUID     guidActivityID;
    GUID     guidTransactionID;
    GUID     guidContextID;
    BSTR     bstrMachineName;
    BSTR     bstrSourceFileName;
    BSTR     bstrModuleName;
    BSTR     bstrMethodName;
    DWORD    dwLineNumber;
    BSTR     bstrDescription;
    IID      iidError;
    FILETIME eventTime;
  }LOG_ENTRY; 

  HRESULT LogError ([in]LOG_ENTRY* pErrorEntry);
  HRESULT LogMethod([in]LOG_ENTRY* pMethodEntry);
  HRESULT LogEvent ([in]LOG_ENTRY* pEventEntry);
};

The helper macros collect the information on the application side, pack it into a LOG_ENTRY struct, create a COM+ event class that implements ILogbook, and fire the appropriate event. The logbook receives the event, formats it appropriately (to HTML or XML), and writes it to the log file.

Deciding to use COM+ events was the easy part of the design. Deciding how to channel all the events to the same logbook component and how to collect all the tracing information you are interested in is more challenging.

To solve the first challenge, you can use COM+ instance managements services. The components in the logbook ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required