zoukankan      html  css  js  c++  java
  • c# 日志 分类: .NET 20121217 14:16 1182人阅读 评论(0) 收藏

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    
    namespace comback
    {
        class LogManager
        {
            //<summary>
            //保存日志的文件夹
            //<summary>
            private static string logPath = AppDomain.CurrentDomain.BaseDirectory;
    
    
            //<summary>
            //写日志
            //<summary>
            public static void WriteLog(LogFile logFile, string msg)
            {
                WriteLog(logFile.ToString(), msg);
            }
            //<summary>
            //写日志
            //<summary>
            public static void WriteLog(string logFile, string msg)
            {
                try
                {
                    System.IO.StreamWriter sw = System.IO.File.AppendText(
                            logPath + logFile + " " +
                            DateTime.Now.ToString("yyyyMMdd") + ".Log"
                        );
                    sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:  ") + msg);
                    sw.Close();
                }
                catch (Exception ee)
                {
                    //System.Windows.Forms.MessageBox.Show("在LogManager类中操作WriteLog方法时异常:" + ee.Message);
                }
            }
    
    
            public static void WriteDownLoadProcess(string message)
            {
                try
                {
                    System.IO.StreamWriter sw = System.IO.File.AppendText(
                            logPath + "result.Log"
                        );
                    sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:  ") + message);
                    sw.Close();
                }
                catch (Exception ee)
                {
                    System.Windows.Forms.MessageBox.Show("在LogManager类中调用方法WriteDownLoadProcess方法时异常:" + ee.Message);
                }
            }
        }
        //<summary>
        //日志类型
        //<summary>
        public enum LogFile
        {
            XmlError,
            OtherError
        }
    }


  • 相关阅读:
    scala :: , +:, :+ , ::: , ++ 的区别
    Scala 函数式编程思想
    Scala 关键字
    HDFS 的内存存储是什么?
    LRU
    高并发情况限流
    Java中List集合去除重复数据的方法
    MySQL支持的跨库事务
    死磕ConcurrentHashMap 1.8源码解析
    一致性Hash算法
  • 原文地址:https://www.cnblogs.com/configman/p/4657574.html
Copyright © 2011-2022 走看看