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

  • 相关阅读:
    聊聊Docker数据卷和数据卷容器
    Nginx虚拟主机
    Shell文本处理四剑客
    Docker镜像、容器剖析
    Tomcat性能优化及JVM内存工作原理
    Nginx动静分离架构&&HA-LB集群整合
    Mysql主从复制架构实战
    Mysql编译安装详解
    Apache虚拟主机实战
    Ansible性能调优
  • 原文地址:https://www.cnblogs.com/rhythmK/p/2491572.html
Copyright © 2011-2022 走看看