Log.cs 954 字节
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 time = string.Format("[{0:HH:mm:ss}] ", DateTime.Now);
            LogBox.AppendText(time + s + "\r\n");
            //LogBox.SelectionStart = LogBox.Text.Length;
            LogBox.ScrollToCaret();
        }

    }
}