Reputation: 21855
we have several applications in Vb.Net using the built in log system (My.Log) to write log information. Until now this system was configured by the application.config file before execution but now we want to let the user to choose some options.
Is there a way that does not requires to parse the XML file and process it? Is there available something like My.Settings that will do the dirty job done?
Thanks in advance.
An example would be to be able to modify the DefaultSwitch value from Verbose to Warning or changing a property of the FileLog like the maxFiles attribute:
<switches>
<add name="DefaultSwitch" value="Verbose" />
</switches>
<sharedListeners>
<add name="FileLog" type="Sipro.Utils.ExtendedLogTraceListener, Sipro.Utils, Version=1.0.6.0, Culture=neutral, PublicKeyToken=null"
autoflush="True"
delimiter=" - "
diskspaceexhaustedbehavior="DiscardMessages"
includehostname="False"
logfilecreationschedule="Daily"
maxfiles="31"
fullinformation="True"
includeDate="True"
includeTicks="True"/>
Upvotes: 1
Views: 328
Reputation: 55059
Might depend on what settings you want to be able to set but if for example the user wants to select the path to where a file log is written I think this might work:
My.Log
has the TraceSource
property which has a Listeners
collection. If it contains a FileLogTraceListener
you should be able to cast that and then set/get it's Location
property.
And the EventLogTraceListener
can set the EventLog
etc.
Upvotes: 1