private void OnChanged(object sender, FileSystemEventArgs e) { try { watcher.EnableRaisingEvents = false; if (file != null && file.FileName.Contains(e.FullPath)) { Console.WriteLine("file is not null {0}", file.LastPosition); file = LogReader.GetFileFromPath(e.FullPath, file.LastPosition); } else { Console.WriteLine("file is null"); file = LogReader.GetFileFromPath(e.FullPath); } var logs = file.Logs; messageHubContext.Clients.All.InvokeAsync("send", logs); } finally { watcher.EnableRaisingEvents = true; } }
public ICollection <LogItem> Read() { string filePath = $@"{hostingEnvironment.WebRootPath}\commonShort.log"; var logFile = LogReader.GetFileFromPath(filePath); return(logFile.Logs); }