免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
C#日志類
public static class LogHelper    {        private static readonly Queue<Dictionary<string, string>> Que = new Queue<Dictionary<string, string>>();        private static readonly Object Object = new Object();        private static EnumLogLevel LogType { get; set; }        static LogHelper()        {            ThreadPool.QueueUserWorkItem(s =>            {                while (true)                {                    if (Que.Count <= 0)                    {                        Thread.Sleep(5000);                        continue;                    }                    lock (Object)                    {                        if (Que.Count <= 0)                        {                            Thread.Sleep(5000);                            continue;                        }                        var currentDirectory = AppDomain.CurrentDomain.BaseDirectory;                        var path = string.Format("{0}Logs\\", currentDirectory);                        if (!Directory.Exists(path)) { Directory.CreateDirectory(path); }                        var fileName = Path.Combine(path, DateTime.Now.ToString("yyyy-MM-dd") + ".log");                        using (var fs = new FileStream(fileName, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite))                        {                            using (var sw = new StreamWriter(fs))                            {                                sw.BaseStream.Seek(0, SeekOrigin.End);                                var col = Que.Dequeue();                                foreach (KeyValuePair<string, string> m in col)                                {                                    sw.WriteLine(m.Key + ":{0}", m.Value);                                }                                sw.Flush(); sw.Dispose(); sw.Close();                            }                        }                    }                }            });        }        public static string WriteLog(this string str, EnumLogLevel type = EnumLogLevel.Info)        {            var logLevel = ConfigurationManager.AppSettings["LogLevel"];            var level = string.IsNullOrWhiteSpace(logLevel) ? EnumLogLevel.Info.ToString() : logLevel;            if ((int)type < (int)Enum.Parse(typeof(EnumLogLevel), level))            {                return string.Empty;            }            lock (Object)            {                LogType = type;                var st = new StackTrace(new StackFrame(1, true));                StackFrame sf = st.GetFrame(0);                var dic = new Dictionary<string, string>                {                    {"發(fā)生時(shí)間", DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss:ffff dddd")},                    {"日志級別", LogType.ToString()},                    {"日志消息", str},                    {"當(dāng)前方法", sf.GetMethod().Name},                    {"發(fā)生位置", st.ToString()}                };                Que.Enqueue(dic);            }            return str;        }    }    /// <summary>    /// All: 表示最低的日志等級。    /// Debug: 這個等級表示用于調(diào)試程序的正常的事件信息;    /// Info: 默認(rèn)的等級    /// Warn: 表示可能對系統(tǒng)有損害的情況;    /// Error: 表示較嚴(yán)重的錯誤等級,但是程序可以繼續(xù)運(yùn)行的信息;    /// Fatal: 表示非常嚴(yán)重的錯誤等級,記錄極有可能導(dǎo)致應(yīng)用程序終止運(yùn)行的致命錯誤信息;    /// Off: 表示最高的等級,如果一個logger的等級標(biāo)記為Off, 將不會記錄任何信息;    /// </summary>    public enum EnumLogLevel    {        All,        Debug,        Info,        Warn,        Error,        Fatal,        Off    }

 

本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊舉報(bào)
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
C#使用讀寫鎖處理多線程并發(fā)寫入文件問題
判斷兩個數(shù)組是否相同
Unity日志工具
C# 利用Selenium實(shí)現(xiàn)瀏覽器自動化操作
解讀ASP.NET 5 & MVC6系列(9):日志框架
WPF DataGrid 導(dǎo)出Excel
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服