Skip to content

Instantly share code, notes, and snippets.

@isdaviddong
Last active November 22, 2017 04:58
public class Logging : PolicyInjectionAttributeBase
{
//指定Log File Name
public string LogFileName { get; set; }
//override AfterInvoke方法
public override void AfterInvoke()
{
var msg = $"\r\n Method '{this.MethodBase.Name}' has been called - {DateTime.Now.ToString()} ";
SaveLog(msg);
}
//寫入Log
private void SaveLog(string msg)
{
if (System.IO.File.Exists(LogFileName))
{
System.IO.File.AppendAllText(LogFileName, msg);
}
else
{
System.IO.File.WriteAllText(LogFileName, msg);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment