Esempio n. 1
0
        public void Threshold_default_should_be_Info()
        {
            Log4NetConfigurator.Configure(new ConsoleAppender());

            LogManager.GetLogger("Test").Debug("Testing Debug");
            LogManager.GetLogger("Test").Info("Testing Info");
        }
Esempio n. 2
0
        protected void Application_Start(object sender, EventArgs e)
        {
            var currentAssembly = typeof(MyCanvasAppActionInvoker).Assembly;
            var domainAssemblies = new[]
                                   	{
                                   		typeof (IApplicationSettings).Assembly,
                                   		typeof (IPlatformConfiguration).Assembly,
                                        currentAssembly
                                   	};

            // IOC
            _container = new CommonContainer();
            _container.RegisterTypes(new Dictionary<Type, Type> { { typeof(IActionInvoker), typeof(MyCanvasAppActionInvoker) } });

            var log4NetConfigurator = new Log4NetConfigurator { Container = _container };
            log4NetConfigurator.Configure();

            _container.AutoWire(domainAssemblies);

            RoutesRegistrar.RegisterRoutes(RouteTable.Routes, new[] { currentAssembly });
            var controllerTypes = RoutesRegistrar.GetControllerTypes(new[] { currentAssembly }).ToArray();
            _container.RegisterTransients(controllerTypes);
            var controllerFactory = new WindsorControllerFactory(_container);
            ControllerBuilder.Current.SetControllerFactory(controllerFactory);

            // Events
            _container.AutoWireEvents(domainAssemblies);
        }
Esempio n. 3
0
    public void InCode()
    {
        #region Log4NetInCode

        var layout = new PatternLayout
        {
            ConversionPattern = "%d [%t] %-5p %c [%x] - %m%n"
        };
        layout.ActivateOptions();
        var consoleAppender = new ColoredConsoleAppender
        {
            Threshold = Level.Debug,
            Layout    = layout
        };
        consoleAppender.ActivateOptions();
        var appender = new RollingFileAppender
        {
            DatePattern        = "yyyy-MM-dd'.txt'",
            RollingStyle       = RollingFileAppender.RollingMode.Composite,
            MaxFileSize        = 10 * 1024 * 1024,
            MaxSizeRollBackups = 10,
            LockingModel       = new FileAppender.MinimalLock(),
            StaticLogFileName  = false,
            File         = @"nsb_log_",
            Layout       = layout,
            AppendToFile = true,
            Threshold    = Level.Debug,
        };
        appender.ActivateOptions();

        BasicConfigurator.Configure(appender, consoleAppender);
        Log4NetConfigurator.Configure();

        #endregion
    }
Esempio n. 4
0
        public static void Main(string[] args)
        {
            Log4NetConfigurator.Configure();

            var tasksPerThread = TasksToSend / ThreadCount;
            var tasks          = new Task[ThreadCount];

            var time = DateTime.UtcNow;

            while (DateTime.UtcNow.Subtract(time).TotalMinutes < 5)
            {
                var elapsed = DateTime.UtcNow.Subtract(time).TotalSeconds;
                if ((int)(elapsed * 1000) % 250 == 0)
                {
                    Log.Info($"Time elapsed: {elapsed}. Messages sent: {TaskNumber}.");
                }

                for (int i = 0; i < tasks.Length; i++)
                {
                    tasks[i] = Task.Run(() => Publish(GenerateTasks(tasksPerThread)));
                }
                try
                {
                    Task.WaitAll(tasks);
                }
                catch (AggregateException e)
                {
                    Log.Error(e.InnerException.Message);
                }
            }
        }
Esempio n. 5
0
        public void Threshold_should_be_All()
        {
            Log4NetConfigurator.Configure(new ConsoleAppender {
                Threshold = Level.All
            });

            LogManager.GetLogger("Test").Debug("Testing Debug");
        }
Esempio n. 6
0
        public void Start(string baseUrl)
        {
            Log4NetConfigurator.Configure();

            Welcome();

            _initializer.OneTimeStartup();

            // If you got "access denied" exception, run this app in elevated mode or allow the tcp port for the app.
            _webApp = WebApp.Start <Startup>(baseUrl);
        }
Esempio n. 7
0
        public void Test()
        {
            var loggerFactory = new Log4NetLoggerFactory();

            global::log4net.LogManager.ResetConfiguration();
            Log4NetConfigurator.Configure(new ConsoleAppender {
                Threshold = Level.All
            });

            var log = loggerFactory.GetLogger("Test");

            Assert.IsInstanceOf <Log4NetLogger>(log);

            CallAllMethodsOnLog(log);

            log = loggerFactory.GetLogger(typeof(LoggerFactoryTests));

            CallAllMethodsOnLog(log);
        }
Esempio n. 8
0
        public static void Main(string[] args)
        {
            Log4NetConfigurator.Configure();

            Metric.Config
            .WithHttpEndpoint("http://localhost:1234/metrics/")
            .WithAllCounters()
            .WithInternalMetrics()
            .WithReporting(config => config.WithConsoleReport(TimeSpan.FromSeconds(30)));

            var tasks = new Task[ThreadCount];

            for (int i = 0; i < ThreadCount; i++)
            {
                var i1 = i;
                tasks[i] = Task.Run(() => Consume(i1.ToString()));
            }
            Task.WaitAll(tasks);
        }
 public void Configure(IConfigureThisEndpoint specifier)
 {
     // setup your logging infrastructure then call
     Log4NetConfigurator.Configure();
 }