水果音乐,微型摆线针轮减速机,克拉卡奇
/// <summary> /// 日志处理帮助类 /// </summary> public class loghelper { private static queue<string> errorqueue = new queue<string>(); static action<string> erroraction; static string logpath => system.web.hosting.hostingenvironment.mappath($"/app_data/log/{datetime.now.tostring("yyyymmdd")}.txt"); static loghelper() { erroraction += writefile; task.run(() => { while (true) { if (errorqueue.count > 0) { lock (errorqueue) { var txt = errorqueue.dequeue(); //出队列 erroraction?.invoke(txt); //写日志 } } else { task.delay(100); } } }); } /// <summary> /// 讲内容写入日志队列中 /// </summary> /// <param name="errortext"></param> public static void writelog(string errortext) { lock (errorqueue) { errorqueue.enqueue(errortext); //进队列 } } /// <summary> /// 写入文本文件 /// </summary> /// <param name="txt"></param> static void writefile(string txt) { using (system.io.filestream fs = new system.io.filestream(logpath, system.io.filemode.append, system.io.fileaccess.write)) { var bytestr = encoding.default.getbytes(txt); fs.write(bytestr, 0, bytestr.length); } } }
asp.net mvc日志处理帮助类
看到公司框架日志处理类写得~~~哎,不想说了。nuget装了log4net然而都不用。。。只能改造一下凑合用了
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
Net Core Web Api项目与在NginX下发布的方法
asp.net core3.1 引用的元包dll版本兼容性问题解决方案
IdentityServer4实现.Net Core API接口权限认证(快速入门)
ASP.NET Core MVC通过IViewLocationExpander扩展视图搜索路径的实现
网友评论