EL6 - Logging block creating multiple log files

Topics: Logging Application Block
Jun 16, 2013 at 4:03 PM
Edited Jun 16, 2013 at 4:04 PM
I'm studying the EntLib 6 logging block and on a simple flat file logging test I'm getting multiple log files. Here is what I mean :

This is the simple C# code
 var logger = new LogWriterFactory().Create();

 if (logger.IsLoggingEnabled())
      logger.Write("First message");
      logger.Write("Second message");
When I run my app for the first time, the TRACE.LOG file is created correctly. But when I run it a few more times.. this is what happens :


multiple files are created
Jun 16, 2013 at 11:51 PM
Edited Jun 20, 2013 at 4:04 PM
This behavior is caused when separate trace listeners attempt to write to the same file. The trace listener locks the file it is logging to so any attempt by another trace listener (or "the same trace listener" in another app domain/process) to write to the same file will cause a new file to be created with a guid prepended to the name.

That might be enough of a lead to get it sorted out. If not, then post your configuration and I can take a look for you.

Randy Levy
Enterprise Library support engineer
Support How-to