0

In my application i have configured the Trace listener as below

"HelloWorld" is my AssemblyName and Namespace

<system.diagnostics>
<sources>
  <source name="DebugCategory" switchName="DebugSwitch" switchType="System.Diagnostics.SourceSwitch">
    <listeners>
      <remove name="Default"/>
      <!-- Add the listeners below -->
      <add name="LogFile"/>
    </listeners>
  </source>
</sources>
<sharedListeners>
 <add name="Console" type="System.Diagnostics.ConsoleTraceListener" initializeData="true"/>
 <add name="LogFile" type="HelloWorld.Diagnostics.FileLogTraceListener, HelloWorld" initializeData="HelloWorld.log" traceOutputOptions="DateTime" cycle="Month"/>
</sharedListeners>

While creating an installer using WIX, in my WIX file i will make the Target exe file from "HelloWorld.exe" to "MyWorld.exe" as below

  <Component Id="MyWorld.exe" Guid="*">
    <File Id="MyWorld.exe" Name="MyWorld.exe"
        DiskId="1" Source="HelloWorld.exe" />
    <Shortcut Id="HelloWorld.menu.exe" Name="Hello world application" Directory="McnMenu" Advertise="yes" WorkingDirectory="INSTAL32LLOCATION" />
  </Component>

Since there is change in the EXE name, Tracelistener is not creating a log file.

Target name should be "Myworld.exe", If i revert the File element to

     <File Id="HelloWorld.exe" Name="HelloWorld.exe" /> 

it works well

Can any one help me.

Yan Sklyarenko
  • 31,557
  • 24
  • 104
  • 139
Sanjaybxl
  • 63
  • 8

1 Answers1

1

In this line of your .config file:

<add name="LogFile" type="HelloWorld.Diagnostics.FileLogTraceListener, HelloWorld" initializeData="HelloWorld.log" traceOutputOptions="DateTime" cycle="Month"/>

You have type="HelloWorld.Diagnostics.FileLogTraceListener, HelloWorld". That is a reference to a class in an assembly. The assembly name (the name of the file) is the part after the comma. Therefore your .config file requires the assembly (the executable in your case) to be named "HelloWorld".

To fix you can either leave the file name HelloWorld.exe (as you found) or change the .config file like so:

<add name="LogFile" type="HelloWorld.Diagnostics.FileLogTraceListener, MyWorld" initializeData="HelloWorld.log" traceOutputOptions="DateTime" cycle="Month"/>

Notice the MyWorld in the type after the comma.

Rob Mensching
  • 33,834
  • 5
  • 90
  • 130