public void Invoke(IInvocation invocation)
        {
            Exception exception = null;

            for (int i = 0; i < 3; i++)
            {
                try
                {
                    invocation.Proceed();
                    return;
                }
                catch (TException we)
                {
                    exception = we;
                    // we will retry here, since we assume that the failure is trasient
                    logger.Info("Exception occured, attempt #" + (i + 1) + ", retrying...", we);
                }

                // if we are here we got an exception, we will assume this is a
                // trasient situation and wait a bit, hopefully it will clear up
                Thread.Sleep(100);
            }
            if (exception == null)
            {
                return;
            }
            logger.Error("All retries failed", exception);
            ExceptionHelper.PreserveStackTrace(exception);
            throw exception;
        }
Exemple #2
0
        public static void Main(string[] args)
        {
            var logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());

            XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));
            DefaultLogger.Info("Application initializing...");
            IWebHost webHost = CreateWebHostBuilder(args).Build();

            MainStaticDataProvider.Initialize(webHost.Services);
            DefaultLogger.Info("Application initialized!");
            webHost.Run();
        }
        public void Capturing_should_allow_customization_of_output_data_not_specified()
        {
            var target = new ConsoleTargetBuilder {
                Layout = "{Time}"
            }.Build();

            DefaultLogger logger = new DefaultLogger(null, target);
            var           evt    = new MyEvent();

            logger.Info(evt);
            Assert.Equal(0, evt.Count);
        }
        public void Capturing_should_allow_customization_of_output_data()
        {
            var target = new ConsoleTargetBuilder {
                Layout = "{Time} {Data}"
            }.Build();

            // Because {Data} is present
            DefaultLogger logger = new DefaultLogger(null, target);
            var           evt    = new MyEvent();

            logger.Info(evt);
            Assert.Equal(1, evt.Count);
        }
Exemple #5
0
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        //[STAThread]
        //static void Main()
        //{
        //    Application.EnableVisualStyles();
        //    Application.SetCompatibleTextRenderingDefault(false);
        //    Application.Run(new MyShadowsocks.View.ConfigForm());
        //}



        static void Main()
        {
            DefaultLogger.Info("Test logger");



            MainAsync().Wait();



            Console.WriteLine("Ready to exit.");
            Console.ReadKey();
        }
Exemple #6
0
        public static void Info(object message, System.Exception ex)
        {
            switch (LogEngineType)
            {
            case LogEngineTypeEnum.DefaultLogger:
                DefaultLogger.Info(message, ex);
                break;

            case LogEngineTypeEnum.FlashLogger:
                FlashLogger.Info(message, ex);
                break;
            }
        }
        public void Info_RandomString_Void()
        {
            // arrange.

            var test = new DefaultLogger();

            // act.
            test.Info("yay", this);

            // assert.
            Assert.IsNotNull(test);

        }
        protected virtual void CreateLogger()
        {
            Logger = new DefaultLogger(GetType().Name);

            Logger.Info("{0}.CreateLogger", GetType().Name);
        }
Exemple #9
0
 /// <summary>
 /// 配置更改时
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private static void MuxerConfigurationChanged(Object sender, EndPointEventArgs e)
 {
     _consoleLogger.Info("Configuration changed: " + e.EndPoint);
 }