• C#写日志


       private static readonly ILog mlog = LogManager.GetLogger(typeof(Message));(命名空间log4net,需要下载log4net.dll)
      private delegate void WriteMsgHandler(string msg);

            public static void LogMessage(ILog mlog,  string strMsg)
            {
                mlog.Info(strMsg);
               AppendTextBoxMsg(strMsg);
            }

     public void AppendTextBoxMsg(string msg)
            {
                try
                {
                    if (txtBox == null)
                    {
                        txtBox = FindControl();
                    }
                    WriteMsgHandler wmHandler = new WriteMsgHandler(DisplayMsg);
                }
                catch(Exception ex)
                {

                }
            }
            private void DisplayMsg(string msg)
            {
                if (txtBox.Lines.Length == 3000)
                {
                    txtBox.Clear();
                }
                msg = "**************" + msg + " <时间:" + DateTime.Now.ToString() + ">************* ";
                txtBox.AppendText(msg);
            }

  • 相关阅读:
    课程作业02
    课后作业01
    大道至简第一章伪代码
    《大道至简》读后感
    Codeforces 959 F. Mahmoud and Ehab and yet another xor task
    Codeforces 992 E. Nastya and King-Shamans
    Codeforces 835 F. Roads in the Kingdom
    Codeforces 980 D. Perfect Groups
    洛谷 P4315 月下“毛景树”
    JDOJ 1234: VIJOS-P1052 高斯消元
  • 原文地址:https://www.cnblogs.com/xiaogongzhu/p/3826769.html
Copyright © 2020-2023  润新知