/Rhino.Etl.Cmd/RhinoEtlRunner.cs
http://github.com/ayende/rhino-etl · C# · 45 lines · 41 code · 4 blank · 0 comment · 1 complexity · fedab561c03cfa6ef0b00bb032decd44 MD5 · raw file
- namespace Rhino.Etl.Cmd
- {
- using System;
- using System.IO;
- using Common.Logging.Configuration;
- using Common.Logging.Log4Net;
- using Core;
- using log4net;
- using log4net.Config;
- public class RhinoEtlRunner : MarshalByRefObject
- {
- private readonly ILog log = LogManager.GetLogger(typeof (RhinoEtlRunner));
- public static void SetupLogging(bool verbose)
- {
- Common.Logging.LogManager.Adapter = new Log4NetLoggerFactoryAdapter(new NameValueCollection());
- string configurationName = "Rhino.Etl.Cmd.standard.log4net.config";
- if (verbose)
- configurationName = "Rhino.Etl.Cmd.verbose.log4net.config";
- using (Stream stream = typeof(RhinoEtlSetup).Assembly.GetManifestResourceStream(configurationName))
- XmlConfigurator.Configure(stream);
- }
- public void Start(Type type, bool verboseLogging)
- {
- try
- {
- SetupLogging(verboseLogging);
- EtlProcess process = (EtlProcess)Activator.CreateInstance(type);
- process.Execute();
- foreach (Exception error in process.GetAllErrors())
- {
- log.Debug(error);
- log.Error(error.Message);
- }
- }
- catch (Exception e)
- {
- log.Error(e);
- }
- }
- }
- }