views:

313

answers:

1

Hi,

I'm using MS log application block for logging my application event into a file called app-trace.log which located on the c:\temp folder.

I'm trying to find the best way to read this file at runtime and display it when the user asks for it. now i have 2 issues:

  1. it seems that this kind of feature is not supported by the framework, hence i have to write this reader myself. am i missing something here? is there any better way of getting this data (w/o buffering it in the memory or saving it into another file).

  2. if i'm taking the only alternative that left for me, and implementing the reader myself, when i'm tring to do:

System.IO.FileStream fs = new System.IO.FileStream(@"c:\temp\app-trace.log", FileMode.Open, FileAccess.Read);

i'm getting "File being used by another process c#", probably the file is locked by the application block. is there any way to access and read it anyhow?

Thank

+1  A: 

You are correct that Enterprise Library does not support this.

If you must retrieve the data from file then you should be able to do it by using the following:

FileStream fs = new FileStream(@"c:\trace.log", FileMode.Open, FileAccess.Read, FileShare.ReadWrite);


I'm curious why the users need access to the log files? Is it for support? If this is a server application, then I would probably seriously consider logging to a database and then retrieving the data from the database when the user wants to view the log information.

Tuzo