I've set up the Enterprise Library Logging Application Block to log in a file called 'app.log' residing in the execution path of my application. This application is a Windows service which runs a configuration website on top of it, where I now want to show the contents of the log file.
Getting the log file was a rather easy task:
var config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
var logSection = config.GetSection("loggingConfiguration") as LoggingSettings;
var lookup = logSection.TraceListeners
.Where(x => x is RollingFlatFileTraceListenerData).FirstOrDefault() as RollingFlatFileTraceListenerData;
if(lookup != null) {
var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, lookup.FileName);
return File.ReadAllText(_logFilePath);
}
However, the RollingFlatFileTraceListener I've set up constantly BLOCKS the file I want to read from. Is there any possibility to access it?
LoggingSettings log = config.GetSection("loggingConfiguration") as LoggingSettings;- Kiquenet