EL6 - Logging block creating multiple log files

Topics: Logging Application Block
Jun 16, 2013 at 5:03 PM
Edited Jun 16, 2013 at 5: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 :

df13a7b0-3de6-4abd-8ccc-b1a5b7bc4b68trace.log
6a1134e2-c1d2-4dc5-98c6-63827b5ec00ctrace.log
813a8b81-bc7f-4730-8b9a-2452830f49a1trace.log
d4d2a3dc-ad4c-47bc-a15a-36ad694bb120trace.log
trace.log

multiple files are created
Jun 17, 2013 at 12:51 AM
Edited Jun 20, 2013 at 5: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
entlib.support@live.com
Enterprise Library support engineer
Support How-to