/Logging.cs Secret
Last active
November 22, 2017 04:58
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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