getting values from ent lib config files

Topics: Building and extending application blocks, General discussion, Logging Application Block
Nov 21, 2008 at 1:48 PM

wondering if anyone can point me in the right direction.

trying to read some data from an existing app.config for an ent lib section.  speficically, i want to get to the filename used by my RollingFlatFileTraceListener at runtime.  i'm not having much luck parsing down thru the xml w/ configurationmanager, but it would seem that i could somehow instantiate a RollingFlatFileTraceListenerData object and grab the property value, but either way, haven't figured out how to get at this information.


Nov 21, 2008 at 2:30 PM
Hi Chris,

Try this sample code:


string loggingConfigurationSectionName = "loggingConfiguration";



LoggingSettings entLibConfig = (LoggingSettings)ConfigurationManager.GetSection(loggingConfigurationSectionName);



RollingFlatFileTraceListenerData data = entLibConfig.TraceListeners.Get("Rolling Flat File Trace Listener") as RollingFlatFileTraceListenerData;



string fileName = data.FileName;

Valiant Dudan
Global Technology and Solutions
Avanade, Inc.


Nov 21, 2008 at 2:48 PM


Thanks a million for that, it was the LoggingSettings typing that I wasn't getting.  I should have found that but I got so buried in the source code for the logging block I couldn't see the forest for the trees.