Log.cs 977 字节
using System;

namespace Model
{
    public class Log
    {
        private readonly log4net.ILog LOG;

        public Log(string name)
        {
            LOG = log4net.LogManager.GetLogger(name);
        }

        public System.Windows.Forms.TextBox LogBox { set; get; }

        public void Info(string s)
        {
            LOG.Info(s);
        }

        public void Debug(string s)
        {
            LOG.Debug(s);
        }

        public void Warn(string s)
        {
            LOG.Warn(s);
        }

        public void Error(string s, Exception ex)
        {
            LOG.Error(s, ex);
        }

        public void UI_Display(string s)
        {
            if (LogBox == null) return;
            string text = string.Format("[{0:HH:mm:ss}] {1}\r\n", DateTime.Now, s);

            LogBox.Invoke(new Action(() =>
            {
                LogBox.AppendText(text);
                LogBox.ScrollToCaret();
            }));

        }

    }
}