Mon, Aug 8 2005 4:04 PM Erwyn van der Meer

Unexpected file roll over with Rolling File Sink due to file system tunneling

Today I experienced some strange unexpected log file roll-overs when logging messages using the EntLib extension RollingFileSink. That's an extension I blogged about a month ago

I had set a age threshold of 1 day, but instead of rolling over once a day, the RollingFileSink started a new log file for each log entry. Rechecking the configuration multiple times I found nothing wrong with the configuration. Clearing the entire log directory did not help either. The RollingFileSink created a fresh log file, but that file still wasn't reused. Strangely enough another log file with identical settings (apart from the filename) was reused and did not roll over.

So I fired up the debugger and was surprised to see that the RollingFileSink considered the fresh file to be older than 1 day. Digging a little deeper revealed that the file was 40 days old! Then I remembered reading about file system tunneling in Raymond Chen's blog. When the file is deleted, the file system remembers the creation datetime. When the file reappears within a short interval, instead of getting the current datetime as its creation date, it gets the old value. Yikes, but Raymond explains why file system tunneling exists. More details can be found in this KB article. The default tunneling cache time is 15 seconds.

The moral of this story. Wait at least 15 seconds after deleting a file before creating a new file with the same name if you want the new file to have the correct creation date.

Filed under: ,

# re: Unexpected file roll over with Rolling File Sink due to file system tunneling

Tuesday, August 09, 2005 2:05 AM by Chi Wai Man

thanx for the tip.

# re: Unexpected file roll over with Rolling File Sink due to file system tunneling

Wednesday, September 21, 2005 3:14 AM by Greg

Hello,
i can't download the rollingFileSink.zip file.
The http://blog.hishambaz.com/archive/2005/02/14/317.aspx is not accessible.
Have you got another URL to give me, please.

Thanks in advance.
Greg.

# re: Unexpected file roll over with Rolling File Sink due to file system tunneling

Thursday, September 22, 2005 12:37 PM by Kaushik

I have a fixed this problem, however I don't have the option of posting the dll's, do send me a mail, I shall be sending the dll's back to you.

koushik.roy@rbc.com

# Rolling File Trace Listener Extension for Enterprise Library 2.0

Wednesday, February 15, 2006 11:42 AM by Erwyn van der Meer

I decided to create an EntLib 2.0 version of the Rolling File Sink. My extension is called the Rolling File Trace Listener. It allows log files to roll over based on both age and size limits.