How to configure EntLib 4.1 to trace into multiple different trace files?

Sep 23, 2010 at 12:00 PM


We have a quite large Application which is developed in tree teams but the whole Application is run as an whole unit, one Application. Different teams want to use they own Rolling Flat Trace files because it is easier to read own team's Trace files than the one and only large Trace file.

But how can this be configured?

EntLib reads section called "loggingConfiguration". Is it possible to set multiple logging configuration sections with different target Rolling Flat Trace files and in Application's code to decide which one to use? How to do this in configuration level and/or in program's code?


Sep 23, 2010 at 3:27 PM
Edited Sep 24, 2010 at 1:51 AM

If the team simply wants to use their own rolling trace listener, why not just each of them define a different category in your config file?  The team's code will then just use their own category when logging.

If this doesn't work for you, you can make use of LogWriterFactory to specify a specific configuration source.  In your case, since you have multiple files for logging configuration, you can create an instance of FileConfigurationSource for each and pass if to an instance of LogWriterFactory.

IConfigurationSource configSource = new FileConfigurationSource("logging.config");
LogWriterFactory logWriterFactory = new LogWriterFactory(configSource);
LogWriter logWriter = logWriterFactory.Create();

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.