Device String

A device string is made up of parameters that describe how log devices are configured for a test, thus defining the log device topology. The string is passed to the CWTTLogger::CreateLogDevice function when the user application first starts.

Device string syntax

A device string has three parts: device type, parameter list, and topology configuration. These parts are shown in the following device string syntax.

$<device_type>:<parameter_list>($<child_device1>[; $<child_device2>; ...]) 

For information about device types, see Log Device Types.

Example of a device string

Suppose you want to create a device string that describes a topology in which a local publisher has three subscribers: a log file, a console, and a debugger. You do not need to include the device type or parameter list for a local publisher because the device string is added automatically. Therefore, the resulting device string, which is shown in the following code example, contains only the child devices.


The following code example demonstrates a typical call to the CreateLogDevice function.

hr = CWTTLogger::CreateLogDevice(L"$logfile:file=log.xml,encoding=UNICODE;$console;$debugger", &hDevice); 

The call returns a handle so that your application can refer to this configuration later.

Distributed topologies

To test a client-server configuration, you will need two device strings: one that describes the server-side topology and one that describes the client-side topology. The following list shows examples of the two device strings.

  • Server-side: $logfile;$netsub:port=2204
  • Client-side: $netpub:server=myserver,port=2204

These strings enable the client application to send its traces to the server application through TCP/IP on port 2204.

Setting device strings outside an application

There might be times when you want to change the topology for a test. For example, you might want a test to look different when it is being written than when it is being run. You can allow for topology changes by passing a null device string to the CreateLogDevice funtion. The device string can then be overridden, in order of precedence, from the command line, an environment variable, or the registry.

  • From the command line, you can set the device string by adding a WTTLogDevStr argument to the launch command. For a topology with a local publisher, a log file, and a console, the argument would appear as the following code example shows.


  • You can create an environmental variable named %WTTLogDevStr% and set it to the device string.

  • Your application can set the device string in the registry. Use the following registry location:


    Use a key that is of type string, named WTTLogDevStr, and with its value set to the device string.

    You can also create other keys at this registry location to store predefined device strings. You could then pass WTTLogDevStrPredefine:SomePredefinedName to a function in place of the device string. DTM Logger will look up "SomePredefinedName" in the registry to get the device string.

See Also

Initializing a Log Device, Log Device Types.

Send feedback on this topic
Built on December 10, 2009