Exemplo n.º 1
0
        public void RunUserInterface()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            log4net.Config.BasicConfigurator.Configure();

            var logViewer = new LogViewer2()
            {
                Text      = "Log",
                Threshold = log4net.Core.Level.Info
            };

            logViewer.AddToRoot();

            log.Info("Startup");

            KillAlreadyRunning();

            hagen = new Hagen();
            hagen.Context.Choose = _ => ActionChooser.Choose(hagen.Context, _);

            main = new Main(hagen);

            foreach (var i in this.pluginAssemblyPaths)
            {
                main.LoadPlugin(i);
            }

            main.AddPanel(logViewer);

            if (Popup)
            {
                main.Popup();
            }

            Application.Run(main);
        }
Exemplo n.º 2
0
        public void List()
        {
            var lv = new LogViewer2()
            {
                Size = new Size(800, 400)
            };

            lv.AddToRoot();
            log.Error("error");
            log.Warn("warn");
            var form = lv.AsForm("Log Viewer");

            form.Show();

            foreach (var i in Enumerable.Range(0, 100))
            {
                log.Info(i);
            }

            log4net.ThreadContext.Stacks["NDC"].Push("hello");

            using (new LogScope(log.Info, "hello"))
            {
            }

            try
            {
                String s = null;
                Console.WriteLine(s.Length);
            }
            catch (Exception ex)
            {
                log.Warn("some error", ex);
            }

            Application.Run(form);
        }