/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

  1. namespace Rhino.Etl.Cmd
  2. {
  3. using System;
  4. using System.IO;
  5. using Common.Logging.Configuration;
  6. using Common.Logging.Log4Net;
  7. using Core;
  8. using log4net;
  9. using log4net.Config;
  10. public class RhinoEtlRunner : MarshalByRefObject
  11. {
  12. private readonly ILog log = LogManager.GetLogger(typeof (RhinoEtlRunner));
  13. public static void SetupLogging(bool verbose)
  14. {
  15. Common.Logging.LogManager.Adapter = new Log4NetLoggerFactoryAdapter(new NameValueCollection());
  16. string configurationName = "Rhino.Etl.Cmd.standard.log4net.config";
  17. if (verbose)
  18. configurationName = "Rhino.Etl.Cmd.verbose.log4net.config";
  19. using (Stream stream = typeof(RhinoEtlSetup).Assembly.GetManifestResourceStream(configurationName))
  20. XmlConfigurator.Configure(stream);
  21. }
  22. public void Start(Type type, bool verboseLogging)
  23. {
  24. try
  25. {
  26. SetupLogging(verboseLogging);
  27. EtlProcess process = (EtlProcess)Activator.CreateInstance(type);
  28. process.Execute();
  29. foreach (Exception error in process.GetAllErrors())
  30. {
  31. log.Debug(error);
  32. log.Error(error.Message);
  33. }
  34. }
  35. catch (Exception e)
  36. {
  37. log.Error(e);
  38. }
  39. }
  40. }
  41. }