AMEN – ini files rule

(see Appendix 2 and 3 
http://proceedings.esri.com/library/userconf/proc95/to250/p245.html)

☺

Andrew Coates, ME, MCPD, MCSD MCTS, Developer Evangelist, Microsoft, 1 Epping 
Road, NORTH RYDE NSW 2113
Ph: +61 (2) 9870 2719 • Mob +61 (416) 134 993 • Fax: +61 (2) 9870 2400 • 
http://blogs.msdn.com/acoat
Sent from the new Office<http://office.com/preview>

From: [email protected] [mailto:[email protected]] On 
Behalf Of DotNet Dude
Sent: Wednesday, 3 December 2014 8:37 PM
To: ozDotNet
Subject: Re: TraceSource without config

Bring back the ini files!

On Wed, Dec 3, 2014 at 6:24 PM, Stephen Price 
<[email protected]<mailto:[email protected]>> wrote:
They need to make them JSON as well. (like they did/are doing with project 
files.)
They are just INI files in disguise. :)


On Wed, Dec 3, 2014 at 3:05 PM, Greg Keogh 
<[email protected]<mailto:[email protected]>> wrote:
Chaps, I saw that page, and the code makes sense, but it's an unrealistic 
example as the same program makes the trace source and listens to it.

Last week I created a static TraceSource in one of my general purpose 
libraries, hoping to imitate what some of the Framework classes do, then I 
found that the only way to listen to the library was with a config file wiring 
up the listeners. I didn't want consuming applications (including my own) to 
have to bother with creating config sections, and in some cases config files 
are troublesome. That's when I found it seemed impossible to create the 
listeners programmatically. I'm still pondering...

I have always been rather bewildered and confused by config files since 
Framework 1.0. They're convenient and readable for basic scenarios, but if you 
need dynamic configuration then you're often trawling the web for magic tricks 
(WCF and log4net are classic examples). Even after all these years I still find 
config file examples that contain mysterious things and I wonder "is that a 
standard Framework config section or did someone just invent it?"

Greg K

On 3 December 2014 at 09:54, Tom P 
<[email protected]<mailto:[email protected]>> wrote:
Hi Greg

According to the following page you can have the defaults in the configuration 
file and override things in code as you need dynamically

http://msdn.microsoft.com/en-us/library/ms228984(v=vs.110).aspx

Still need entries in a config file but they can be overridden which is good

Thanks
Tom

On 2 December 2014 at 17:38, Greg Keogh <[email protected]<mailto:[email protected]>> 
wrote:
Folks, many parts of the FCL (like Remoting and WCF) write trace information 
out to a TraceSource class, presumably like this (does this look right?):

private TraceSource ts = new TraceSource("My.Library", SourceLevels.All);
:
ts.TraceInformation("Hello world!");

The only way I can find at the moment to listen to what a library like that is 
tracing is to put something like this in the App's config file:

  <system.diagnostics>
    <sources>
      <source name="My.Library">
        <listeners>
          <add name="consListener" 
type="System.Diagnostics.ConsoleTraceListener"/>
        </listeners>
      </source>
    </sources>
  </system.diagnostics>

Does anyone know how bypass the config section to do this in code? I've been 
fiddling and searching the web but every example or tutorial I find uses a 
config file.

Greg K




Reply via email to