Navigation:  Samples > Advanced >

VBPLogger Sample

Previous pageReturn to chapter overviewNext page

The Visual Build logging architecture supports registration of custom logging components.  Two sample loggers (C# and VB6) show how to create a custom logging component to replace the built-in logging components.  They write to the log file in a custom XML format.

 

The samples are located in the Samples\Misc\VBPLogger folder.  To use:

1.Build the logger project by opening either VBPLogger.csproj (C# version) or VBPLogger.vbp (VB6 version) and building.
2.Open Register.bld and build the related Register step to register the associated logger component with VBP.
3.Go to Tools | Application Options | Logging and change the format to VBPLogger.
4.Go to File | Properties | Logging and delete the log file.
5.Rebuild the Register.bld project to generate a log using the custom logger.

 

To debug, open the project in Visual Studio, set VisBuildPro.exe as the debug executable, and debug the project in the IDE.

 

Visual Build loggers are COM components implementing a standard interface (ILogger, defined in the VisBuildSvr.dll type library) and custom-registered for Visual Build to locate them.  This is done by adding the logging component's ProgId in a registry key under HKEY_LOCAL_MACHINE\SOFTWARE\Kinook Software\Visual Build Professional 10\Logging\<Format>.  During a build, all registered loggers for the log format selected in the Logging options dialog  are instantiated and initialized.  To implement logging, a logging component connects to the build events fired by the Builder object and logs any pertinent information when the events occur.

 

The logging architecture supports multiple logging components for each file format, so a custom format and logger could be defined, or the standard logging component for a given format could be used for logging, and a custom logging component could be used for extended logging functionality (for instance, to generate a summary log file or to write additional information to the main log file).  As an example of writing to a different file, the custom logging component could append 'Summary' to the value of the LOGFILE macro, or it could use a different macro that its log filename could be placed in, and only write failed steps or generate HTML log output.  See the VBPLogger sample for more details.

 

Note: Some of the interfaces defined in the VisBuildSvr type library are marked as hidden; to view the hidden interfaces in the VB Object Browser, right-click and choose Show hidden members.