So I’m using Tracesource to log some errors and wan’t to create a log file in a users local windows document structure ( something like System.Environment.SpecialFolder.LocalApplicationData ).
However I have no idea if I can do anything like that inside a config file.
<system.diagnostics>
<trace autoflush="true"/>
<sources>
<source name="MainSource"
switchName="MainSwitch"
switchType="System.Diagnostics.SourceSwitch" >
<listeners>
<add name="LogFileListener" />
</listeners>
</source>
</sources>
<sharedListeners>
<add name="LogFileListener"
type="System.Diagnostics.TextWriterTraceListener"
initializeData="This is the place the output file goes to"
traceOutputOptions="ProcessId, DateTime, Callstack" />
</sharedListeners>
<switches>
<add name="MainSwitch" value="Verbose" />
</switches>
</system.diagnostics>
initializeData is I think a parameter to the constructor and is where I would have to put a custom path.
The path to the logfile in the config file is absolute and cannot be assumed by any special variables.
However, you could create it dynamically and this should solve your issue
How to: Create and Initialize Trace Sources