0

I have a wpf project which uses trace listeners to record debug information. The tool is used among a number of people and each of them write out the log file in their specific home directory. What I need to achieve is store all log files in a common dir accessible to all users but the file name should be appended with the user name using the tool in that session. For example I tried this:

<system.diagnostics>
    <trace autoflush="false" indentsize="4">
        <listeners>
            <add name="MyListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="Z:\commondir\MyTool-logs\"+WindowsIdentity.GetCurrent().Name.ToString()+"toollog.log"/>
            <remove name="default"/>
        </listeners>
    </trace>
</system.diagnostics>

Basically I want to dynamically assign a different name to the log file based on the user name. However the above code gives me a build error saying the namespace prefix is not defined. How do I overcome this?

john smith
  • 507
  • 6
  • 18

1 Answers1

0

This is definitely possible. However, you will need to rewrite sections of your app.config file at runtime, see Write values in app.config file.

Community
  • 1
  • 1
Contango
  • 76,540
  • 58
  • 260
  • 305