public void Init(LogLocations settings) { _logFiles = settings.Log; foreach (var path in _logFiles) { var dir = System.IO.Path.GetDirectoryName(path); // connect to UNC path if (dir.Contains("\\\\")) { ExtremeMirror.PinvokeWindowsNetworking.connectToRemote(dir, ConfigurationManager.AppSettings["username"], ConfigurationManager.AppSettings["password"] ); } // set up watcher for the directory & files var fw = new FileSystemWatcher(dir); var filter = ""; if (path.Contains("*.")) { filter = path.Substring(path.IndexOf("*.")); fw.Filter = filter; } // set up file sizes so we can diff old vs new var files = Directory.GetFiles(Path.GetDirectoryName(path), filter); SetupFiles(files); fw.Changed += fw_Changed; fw.EnableRaisingEvents = true; } }
static void Main(string[] args) { LogLocations settings = (LogLocations)ConfigurationManager.GetSection("logLocations"); var app = new MultiTailApp(); app.Init(settings); // any key to quit Console.ReadLine(); }
public object Create(object parent, object configContext, System.Xml.XmlNode section) { var szConfig = section.SelectNodes("//logLocations/log"); LogLocations retConf = new LogLocations(); if (szConfig != null) { foreach (XmlNode node in szConfig) { retConf.Log.Add(node.InnerText); } } return(retConf); }