Actually Tom, the page you link to DOES list code "To initialize trace sources, listeners, and filters without a configuration file", though not recommended.
-- Regards, Mark Hurd, B.Sc.(Ma.)(Hons.) On 3 December 2014 at 09:24, Tom P <[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]> 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
