脚本宝典收集整理的这篇文章主要介绍了.NET 日志系统设计思路及实现代码,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
日志很明显是帮助大家定位到问题的一个很重要的手段,本来是想直接使用的NLOG 来做系统的日志工具,哎伤不起,一变态非要说这个有很多不可控制的因素,这里我给大家讲一下我是怎么实现日志模块的,欢迎拍砖
总体架构图
• 在这里我把日子的等级分为 跟踪,BUG 和错误 3种 定义枚举如下
/// <summary>
/// 写入BUG信息
/// </summary>
/// <param name="LogContent"></param>
void WriteBug(string LogContent);
/// <summary>
/// 写入错误信息
/// </summary>
/// <param name="LogContent"></param>
void WriteError(string LogContent);
}
public void WriteBug(string LogContent)
{
throw new NotImplementedException();
}
public void WriteError(string LogContent)
{
throw new NotImplementedException();
}
}
public void WriteBug(string LogContent)
{
throw new NotImplementedException();
}
public void WriteError(string LogContent)
{
throw new NotImplementedException();
}
}
public SmartLog(ILogTarget tragent)
{
this._adaptee = tragent;
}
public void WriteTrack(string LogContent)
{
_adaptee.WriteTrack(LogContent);
}
public void WriteBug(string LogContent)
{
_adaptee.WriteBug(LogContent);
}
public void WriteError(string LogContent)
{
_adaptee.WriteError(LogContent);
}
}
log.WriteTrack("Hello word");
以上是脚本宝典为你收集整理的.NET 日志系统设计思路及实现代码全部内容,希望文章能够帮你解决.NET 日志系统设计思路及实现代码所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。