diff --git a/TimberWinR.ServiceHost/Program.cs b/TimberWinR.ServiceHost/Program.cs index 82136ce..07be258 100644 --- a/TimberWinR.ServiceHost/Program.cs +++ b/TimberWinR.ServiceHost/Program.cs @@ -69,9 +69,7 @@ namespace TimberWinR.ServiceHost _args = args; _cancellationTokenSource = new CancellationTokenSource(); _cancellationToken = _cancellationTokenSource.Token; - _serviceTask = new Task(RunService, _cancellationToken); - - + _serviceTask = new Task(RunService, _cancellationToken); } public void Start() @@ -90,19 +88,19 @@ namespace TimberWinR.ServiceHost /// private void RunService() { - var config = new Configuration(_args.ConfigFile); + TimberWinR.Manager manager = new TimberWinR.Manager(_args.ConfigFile); + var outputRedis = new RedisOutput(new string[] { "tstlexiceapp006.vistaprint.svc", "tstlexiceapp007.vistaprint.svc" }, _cancellationToken); _nlogListener = new TcpInputListener(_cancellationToken, 5140); outputRedis.Connect(_nlogListener); - foreach (Configuration.WindowsEvents eventConfig in config.Events) + foreach (Configuration.WindowsEvents eventConfig in manager.Config.Events) { var elistner = new WindowsEvtInputListener(eventConfig, _cancellationToken); outputRedis.Connect(elistner); } - TimberWinR.Manager manager = new TimberWinR.Manager(_args.ConfigFile); - + //while (!_cancellationTokenSource.IsCancellationRequested) //{ // System.Threading.Thread.Sleep(1000); diff --git a/TimberWinR.UnitTests/testconf.xml b/TimberWinR.UnitTests/testconf.xml index 9b5e2c9..27731ed 100644 --- a/TimberWinR.UnitTests/testconf.xml +++ b/TimberWinR.UnitTests/testconf.xml @@ -2,7 +2,7 @@ - + diff --git a/TimberWinR/Configuration.cs b/TimberWinR/Configuration.cs index cb02bf9..b1f4bda 100644 --- a/TimberWinR/Configuration.cs +++ b/TimberWinR/Configuration.cs @@ -7,6 +7,7 @@ using System.Xml; using System.Xml.Linq; using System.IO; using System.Globalization; +using NLog; using TimberWinR.Inputs; namespace TimberWinR { @@ -33,7 +34,16 @@ namespace TimberWinR public Configuration(string xmlConfFile) { - parseXMLConf(xmlConfFile); + try + { + parseXMLConf(xmlConfFile); + } + catch (Exception ex) + { + LogManager.GetCurrentClassLogger().Error(ex); + throw ex; + } + } static List parseFields_Events(IEnumerable xml_fields) @@ -479,10 +489,7 @@ namespace TimberWinR IISLogs iis = new IISLogs(name, location, fields, args); _iislogs.Add(iis); - } - - - Console.WriteLine("end"); + } } public class WindowsEvents diff --git a/TimberWinR/Inputs/WindowsEvtInputListener.cs b/TimberWinR/Inputs/WindowsEvtInputListener.cs index b5e3e4a..41843a1 100644 --- a/TimberWinR/Inputs/WindowsEvtInputListener.cs +++ b/TimberWinR/Inputs/WindowsEvtInputListener.cs @@ -44,10 +44,15 @@ namespace TimberWinR.Inputs // Instantiate the Event Log Input Format object var iFmt = new EventLogInputFormat() { - direction = _arguments.Direction, binaryFormat = _arguments.BinaryFormat, - iCheckpoint = fileName, + direction = _arguments.Direction, + formatMsg = _arguments.FormatMsg, + fullEventCode = _arguments.FullEventCode, + fullText = _arguments.FullText, + msgErrorMode = _arguments.MsgErrorMode, + stringsSep = _arguments.StringsSep, resolveSIDs = _arguments.ResolveSIDS, + iCheckpoint = fileName, }; // Create the query diff --git a/TimberWinR/Manager.cs b/TimberWinR/Manager.cs index 14cad62..fa7ba62 100644 --- a/TimberWinR/Manager.cs +++ b/TimberWinR/Manager.cs @@ -14,13 +14,10 @@ namespace TimberWinR /// public class Manager { - Configuration Config { get; set; } + public Configuration Config { get; set; } public Manager(string configurationFile=null) - { - // Read the Configuration file - Config = new Configuration(configurationFile); - + { var loggingConfiguration = new LoggingConfiguration(); // Create our default targets @@ -37,7 +34,10 @@ namespace TimberWinR LogManager.Configuration = loggingConfiguration; LogManager.EnableLogging(); - LogManager.GetCurrentClassLogger().Info("Initialized"); + LogManager.GetCurrentClassLogger().Info("Initialized"); + + // Read the Configuration file + Config = new Configuration(configurationFile); } ///