Log file name

Topics: Logging Application Block
Oct 23, 2012 at 2:14 PM


I created a log file, but instead of writing the message to LogFileName.log, a new file was created, called something like 5e5d49c3-e985-446a-8275-557ef11b838dLogFileName.log and the message was written there.

What could cause this ?




Oct 24, 2012 at 4:50 PM

This is caused by file locking in System.Diagnostics.  The reason why you get multiple files is that you are using multiple trace listeners that all point to the destination same file.  Each trace listener locks (or will attempt to lock) the file exclusively.  If it fails to obtain the lock it will create a new file prepended with a GUID.  So you shouldn't create more than one trace listener that points to the same file (or have multiple app domains/processes that write to the same file).

Randy Levy
Enterprise Library support engineer