RTI Connext C# API Version 7.3.0
Logging, version and utilities examples

Miscellaneous examples, such as configuring logging, printing the current version and other utilities.

Miscellaneous examples, such as configuring logging, printing the current version and other utilities.

Sections:

Getting the current RTI Connext version

Example: print the current version

The global entry point to the RTI Connext DDS API.
Definition: ServiceEnvironment.cs:29
static ServiceEnvironment Instance
The singleton instance
Definition: ServiceEnvironment.cs:35
ProductVersion Version
Unique identifier for the build of the RTI Connext DDS Core Libraries
Definition: ServiceEnvironment.cs:40
Contains infrastructure types.
Definition: AsyncWaitSetProperty.cs:18
Contains the RTI Connext DDS C# API.
Definition: AsyncWaitSetProperty.cs:18
Contains the RTI Connext C# API.
Definition: Logger.cs:20

Configuring logging

Example: change the logging verbosity to warnings

The singleton used to configure RTI Connext logging
Definition: Logger.cs:29
void SetVerbosity(Verbosity verbosity)
Set the verbosity at which RTI Connext will log diagnostic information.
static Logger Instance
Get the singleton Logger instance
Definition: Logger.cs:43
Contains configuration utilities, such as logging
Definition: Logger.cs:20

Example: redirect log messages to a file

Logger.Instance.SetOutputFile("MyLogging.txt");

Example: capture logging messages to customize the output

// After installing an event handler, all messages logged by RTI Connext
// will be sent to this handler instead of being printed.
Logger.Instance.MessageLogged += log =>
{
Console.WriteLine($"[RTI Connext Log: {log.Message}]");
CustomLoggingSystem(log.Message);
};

Tracking memory usage

Example: enable the heap monitoring utility to track the memory that the middleware uses internally

// Before any other call to the Connext DDS API:
var heapMonitor = Rti.Utility.HeapMonitor.Enable();
// Use the API...
var participant = DomainParticipantFactory.Instance.CreateParticipant(domainId: 0);
// ...
// TakeSnapshot creates a detailed file that allows tracking the
// memory allocations performed by the middleware on the native heap
var snapshot = heapMonitor.TakeSnapshot("heap01.txt", printDetails: true);
Console.WriteLine($"Initial heap usage is: {snapshot.CurrentHeapUsage}");
participant.Dispose();
snapshot = heapMonitor.TakeSnapshot("heap02.txt", printDetails: true);
Console.WriteLine($"Final heap usage is: {snapshot.CurrentHeapUsage}");
Utility that tracks native heap memory usage by RTI Connext DDS
Definition: HeapMonitor.cs:21
static HeapMonitor Instance
Accesses the singleton that allows taking snapshots. Enable must be called before.
Definition: HeapMonitor.cs:27
Snapshot TakeSnapshot()
Takes a snapshot
static HeapMonitor Enable()
Enables heap memory tracking. Heap monitoring must be explicitly enabled before any other RTI Connext...
Definition: HeapMonitor.cs:43
Contains general-purpose utilities
Definition: Namespaces.cs:141

Network monitoring

Rti.Utility.NetworkCapture allows capturing network traffic that one or more DomainParticipants send or receive. This feature can be used to analyze and debug communication problems between DDS applications.

The Network Capture example in the rticonnextdds-examples GitHub repository shows how to use this feature.