zoukankan      html  css  js  c++  java
  • 写入日志小技巧

     EventLog log = new EventLog("Wodongni.Com");
                //  首先应判断日志来源是否存在,一个日志来源只能同时与一个事件绑定s
                if (!EventLog.SourceExists("New Application1"))
                    EventLog.CreateEventSource("New Application1""Wodongni.Com");
                try
                {
                    log.Source = "New Applications1";
                    log.WriteEntry("处理信息1", EventLogEntryType.Information);
                    log.WriteEntry("处理信息2", EventLogEntryType.Information);
                    throw new System.IO.FileNotFoundException("readme.txt文件未找到");
                }
                catch (System.IO.FileNotFoundException exception)
                {
                    log.WriteEntry(exception.Message, EventLogEntryType.Error);
                }
            private static void WriteMsg(string msg)
            {
                string txtPath = System.AppDomain.CurrentDomain.BaseDirectory+"\\demo.txt";
                StreamWriter sw = new StreamWriter(txtPath, true, System.Text.Encoding.Default);
                 sw.WriteLine("time:"+DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                sw.WriteLine(msg);
                sw.Close();
            }

    http://www.cnblogs.com/nokiaguy/archive/2009/02/26/1398708.html

  • 相关阅读:
    修改MySQL表varchar字段的小实验
    MySQL5.6同步指定数据库
    Redis安装
    MongoDB安装
    RMAN备份注意事项
    Oracle Data Guard Protection Modes
    Linux Shell 文本处理工具
    ORACLE 收缩表空间的数据文件
    crfclust.bdb导致磁盘满
    undo管理
  • 原文地址:https://www.cnblogs.com/rhythmK/p/2491572.html
Copyright © 2011-2022 走看看