private static void WriteToLog(string level, string message, CallerInfo cInfo) { string msg = ""; msg = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss,ff\t") + level + "\t" + cInfo.CallerFilePath + "\t" + cInfo.CallerMemberName + "\t" + cInfo.CallerLineNumber + "\t" + message; if (_semaphore.WaitOne(100)) { if (string.IsNullOrEmpty(_logfn)) { GetLogFn(); string msg1 = "Timestamp\tType\tFile\tMethod\tLine\tMessage"; File.AppendAllLines(_logfn, new List <string> { msg1 }); Assembly asm = Assembly.GetExecutingAssembly(); var version = asm.GetName().Version; string initStamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss,ff\t"); var initstrings = new List <string> { initStamp + "Init\tLog Init\t******************************", initStamp + $"Init\tLog Init\teRechnung Word PlugIn Version {version.ToString()}", initStamp + "Init\tLog Init\t******************************", }; File.AppendAllLines(_logfn, initstrings); } File.AppendAllLines(_logfn, new List <string> { msg }); _semaphore.ReleaseMutex(); } else { // Silently skip Debug.WriteLine("Semaphore not acquired: '" + msg + "'"); } return; }
public static void Warning(string messageTemplate, CallerInfo callerInfo, params object[] propertyValues) { Serilog.Log.Logger .ForHere(callerInfo.CallerFilePath, callerInfo.CallerMemberName, callerInfo.CallerLineNumber) .Warning(messageTemplate, propertyValues); }
public static void Error(Exception ex, CallerInfo callerInfo, string p, params object[] propertyValues) { Serilog.Log.Logger.ForHere(callerInfo.CallerFilePath, callerInfo.CallerMemberName, callerInfo.CallerLineNumber) .Error(ex, p, propertyValues); }