List of Blogs
Search Blogs
Blog Archive

Most recent blog entries

 

Sep13

Written by:Martin
13.09.2007 12:34 

SwyxWare v6.02 uses the standard Microsoft .Net tracing capabilities for newer components. Tracing is control via TraceSwitch objects which are set in the application configuration file, e.g.

<system.diagnostics>
  <switches>
    <add name="CDSClient" value="1" />
    <add name="GC" value="1" />
    <add name="MT" value="1" />
    <add name="PERFM" value="1" />
    <add name="IpPbxSrv" value="4" />
    <add name="PPool" value="1" />
    <add name="Files" value="1" />
    <add name="FileCache" value="1" />
    <add name="Report" value="1" />
    <add name="WSE" value="1" />
    <add name="SCT" value="1" />
    <add name="ChngMgmt" value="4" />
    <add name="ChngMgmtUser" value="4" />
  </switches>
</system.diagnostics>

I often have to change these settings on my development machine or on test systems. Instead of editing the file manually I use Windows Powershell: 

[0] C:\PS ADMIN> get-traceswitch "C:\Program Files (x86)\SwyxWare\IpPbxSrv.exe.config"
name                                                        value
----                                                        -----
CDSClient                                                   1
GC                                                          1
MT                                                          1
PERFM                                                       1
IpPbxSrv                                                    4
PPool                                                       1
Files                                                       1
FileCache                                                   1
Report                                                      1
WSE                                                         1
SCT                                                         1
ChngMgmt                                                    4
ChngMgmtUser                                                4
[0] C:\PS ADMIN> set-traceswitch "C:\Program Files (x86)\SwyxWare\IpPbxSrv.exe.config" Files 4
[0] C:\PS ADMIN> get-traceswitch "C:\Program Files (x86)\SwyxWare\IpPbxSrv.exe.config" Files
name                                                        value
----                                                        -----
Files                                                       4

get-traceswitch is defined like this:

function get-traceswitch($cfgFile,$switch)
{
    $c = [xml](get-content $cfgfile)
    $c.configuration.'system.diagnostics'.switches.add | ? { $_.name -match $switch }
}

The first line assigns the contents of the given config file to variable $c. [xml] ensures that it is of type System.Xml.XmlDocument. The second ine lists all "add" child elements of <switches> matching the given switch name. If $switch is empty the -match operator matches all.

set-traceswitch is almost as simple:

function set-traceswitch($cfgFile,$switch,$switchValue)
{
    $c = [xml](get-content $cfgFile)
    ($c.configuration.'system.diagnostics'.switches.add | where { $_.name -eq $switch }).value = [string]$switchValue
    $c.save($cfgFile)
}

I just retrieve the <add> element which has a name attribute matching the given switch name and set the value property of that element. BTW, setting the old style SwyxWare trace registry values is easy, too:

set-itemproperty hklm:\software\wow6432node\swyx\ippbxsrv\CurrentVersion\Tracing SrvGk 6

 I really like Windows Powershell

Tags:

Your name:
Your email:
(Optional) Email used only to show Gravatar.
Title:
Comment:
Security Code
Enter the code shown above in the box below
Add Comment  Cancel 
Blog Help
Sponsors
bluvo AG
logic-base GmbH
Swyx Solutions AG, Germany

 

Charity

German Aid for Afghan Children

Swyx Forum supports the German Aid for Afghan Children (Kinderhilfe Afghanistan)