static void ConfigureLogging(string botName)
        {
            if (string.IsNullOrEmpty(botName))
            {
                botName = DateTime.Now.ToString("yyyy_MM_dd_HH_mm");
            }

            try
            {
                string log4netpath = ToolConfig.GetLogConfigFile();

                XmlDocument log4netConfig = new XmlDocument();
                log4netConfig.Load(File.OpenRead(log4netpath));

                var repo = log4net.LogManager.CreateRepository(
                    Assembly.GetEntryAssembly(),
                    typeof(log4net.Repository.Hierarchy.Hierarchy));

                log4net.GlobalContext.Properties["Name"] = botName;


                log4net.Config.XmlConfigurator.Configure(repo, log4netConfig["log4net"]);
            }
            catch
            {
                //it failed configuring the logging info; nothing to do.
            }
        }
        static int Main(string[] args)
        {
            BotArguments botArgs = new BotArguments(args);

            botArgs.Parse();

            ConfigureLogging(botArgs.BotName);

            string argsStr = args == null ? string.Empty : string.Join(" ", args);

            mLog.DebugFormat("Args: [{0}]. Are valid args?: [{1}]", argsStr, botArgs.AreValidArgs);

            if (!botArgs.AreValidArgs || botArgs.HasToShowUsage)
            {
                PrintUsage(botArgs.AreValidArgs);
                return(0);
            }

            BotConfiguration botConfig = BotConfiguration.Build(
                botArgs.ConfigFilePath,
                botArgs.RestApiUrl,
                botArgs.WebSocketUrl);

            string errorMessage = null;

            if (!BotConfigurationChecker.CheckConfiguration(botConfig, out errorMessage))
            {
                Console.WriteLine(errorMessage);
                mLog.ErrorFormat(
                    "Bot [{0}] is going to finish: error found on argument check.", botArgs.BotName);

                mLog.Error(errorMessage);
                return(1);
            }

            ConfigureServicePoint();

            LaunchBot(
                botArgs.WebSocketUrl,
                botArgs.RestApiUrl,
                botConfig,
                ToolConfig.GetResolvedBranchesStorageFile(GetEscapedBotName(botArgs.BotName)),
                ToolConfig.GetReadyToMergeBranchesStorageFile(GetEscapedBotName(botArgs.BotName)),
                botArgs.BotName,
                botArgs.ApiKey);

            mLog.InfoFormat(
                "Bot [{0}] is going to finish: orderly shutdown.", botArgs.BotName);

            return(0);
        }