예제 #1
0
        static void DoLog()
        {
            Console.WriteLine("Doing Log!");

            if (_log.IsErrorEnabled)
            {
                _log.Error("This is an Error...");
            }

            if (_log.IsDebugEnabled)
            {
                for (int i = 0; i < 10; i++)
                {
                    _log.Debug("This is a simple log!");
                }
            }

            if (_log.IsErrorEnabled)
            {
                _log.Error("This is an Error...");
            }

            if (_log.IsInfoEnabled)
            {
                _log.Info("This is an Info...");
            }


            _log.Warn("This is a Warning...");
            _log.Fatal("This is a Fatal...");

            _log.Error("This is an error with an exception.", new Exception("The message exception here."));

            _log.Warn("This is a message on many lines...\nlines...\nlines...\nlines...");
            _log.Warn("This is a message on many lines...\r\nlines...\r\nlines...\r\nlines...");

            var dm = new DummyManager();

            dm.DoIt();

            var dt = new DummyTester();

            dt.DoIt();
        }
예제 #2
0
        static void DoLog(char keyChar)
        {
            Console.WriteLine("\nBegin Doing Log!");
            Console.WriteLine(DateTime.Now);
            if (Char.ToLower(keyChar) == 'b')
            {
                for (int i = 0; i < 10000; i++)
                {
                    _log.Info(i);
                }
            }
            else if (keyChar >= '1' && keyChar <= '9')
            {
                _log.Info(keyChar);
            }
            else if (Char.ToLower(keyChar) == 'e')
            {
                try
                {
                    ThrowTestEx();
                    return;
                }
                catch (Exception ex)
                {
                    _log.Error("TestEx", ex);
                }
            }
            else if (Char.ToLower(keyChar) == 'c')
            {
                for (int i = 0; i < 10; i++)
                {
                    _log.Info("测试中文");
                }
            }
            else
            {
                if (_log.IsErrorEnabled)
                {
                    _log.Error("This is an Error...");
                }

                if (_log.IsDebugEnabled)
                {
                    for (int i = 0; i < 10; i++)
                    {
                        _log.Debug("This is a simple log!");
                    }
                }

                if (_log.IsErrorEnabled)
                {
                    _log.Error("This is an Error...");
                }

                if (_log.IsInfoEnabled)
                {
                    _log.Info("This is an Info...");
                }


                _log.Warn("This is a Warning...");
                _log.Fatal("This is a Fatal...");

                _log.Error("This is an error with an exception.", new Exception("The message exception here."));

                _log.Warn("This is a message on many lines...\nlines...\nlines...\nlines...");
                _log.Warn("This is a message on many lines...\r\nlines...\r\nlines...\r\nlines...");

                DummyManager dm = new DummyManager();
                dm.DoIt();

                DummyTester dt = new DummyTester();
                dt.DoIt();
            }

            Console.WriteLine("End Doing Log!");
        }