EDN Admin
Well-known member
Hi
I am using the application config file, App.Config, to create a tracelistener with a specific filename, say "LogFile.txt". The following works to do that:
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; <<span style="color:#A31515; sharedListeners<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; add <span style="color:Red; type<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; System.Diagnostics.TextWriterTraceListener<span style="color:Black; " <span style="color:Red; name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; fileListener<span style="color:Black; " <span style="color:Red; initializeData<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; LogFile.txt<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; </<span style="color:#A31515; sharedListeners<span style="color:Blue; >
[/code]
But I would like to store the filename in my application settings, like this:
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; <<span style="color:#A31515; applicationSettings<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; FeehandlerMain.Properties.Settings<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; setting <span style="color:Red; name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; LogFileName<span style="color:Black; " <span style="color:Red; serializeAs<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; String<span style="color:Black; "<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; value<span style="color:Blue; >LogFile.txt<span style="color:Blue; </<span style="color:#A31515; value<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; setting<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; FeehandlerMain.Properties.Settings<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; applicationSettings<span style="color:Blue; >
[/code]
How can I change the <sharedListeners> add command, to assign the value of the "LogFileName" setting to the "initializeData" parameter?
To be clear, something like:
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; <<span style="color:#A31515; sharedListeners<span style="color:Blue; >
<add type="System.Diagnostics.TextWriterTraceListener" name="fileListener" initializeData=Properties.Settings.Default.LogFileName />
</sharedListeners
[/code]
What would the correct syntax be? Can it be done?
Thanks
PS: Is this the correct forum for this question?
View the full article
I am using the application config file, App.Config, to create a tracelistener with a specific filename, say "LogFile.txt". The following works to do that:
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; <<span style="color:#A31515; sharedListeners<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; add <span style="color:Red; type<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; System.Diagnostics.TextWriterTraceListener<span style="color:Black; " <span style="color:Red; name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; fileListener<span style="color:Black; " <span style="color:Red; initializeData<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; LogFile.txt<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; </<span style="color:#A31515; sharedListeners<span style="color:Blue; >
[/code]
But I would like to store the filename in my application settings, like this:
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; <<span style="color:#A31515; applicationSettings<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; FeehandlerMain.Properties.Settings<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; setting <span style="color:Red; name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; LogFileName<span style="color:Black; " <span style="color:Red; serializeAs<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; String<span style="color:Black; "<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; value<span style="color:Blue; >LogFile.txt<span style="color:Blue; </<span style="color:#A31515; value<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; setting<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; FeehandlerMain.Properties.Settings<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; applicationSettings<span style="color:Blue; >
[/code]
How can I change the <sharedListeners> add command, to assign the value of the "LogFileName" setting to the "initializeData" parameter?
To be clear, something like:
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; <<span style="color:#A31515; sharedListeners<span style="color:Blue; >
<add type="System.Diagnostics.TextWriterTraceListener" name="fileListener" initializeData=Properties.Settings.Default.LogFileName />
</sharedListeners
[/code]
What would the correct syntax be? Can it be done?
Thanks
PS: Is this the correct forum for this question?
View the full article