private static Microsoft.Extensions.Logging.LogLevel GetLogLevel(Common.LogLevel logLevel) { switch (logLevel) { case Common.LogLevel.Debug: return(Microsoft.Extensions.Logging.LogLevel.Debug); case Common.LogLevel.Verbose: return(Microsoft.Extensions.Logging.LogLevel.Information); case Common.LogLevel.Information: return(Microsoft.Extensions.Logging.LogLevel.Information); case Common.LogLevel.Minimal: return(Microsoft.Extensions.Logging.LogLevel.Information); case Common.LogLevel.Warning: return(Microsoft.Extensions.Logging.LogLevel.Warning); case Common.LogLevel.Error: return(Microsoft.Extensions.Logging.LogLevel.Error); } return(Microsoft.Extensions.Logging.LogLevel.None); }
private string FormatFile(string user, string message, Common.LogLevel logLevel) { buildFormat = new StringBuilder(); buildFormat.AppendFormat("Date : {0} \n", DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss")).AppendLine(); buildFormat.AppendFormat("Logtype : {0} \n", logLevel.ToString()).AppendLine(); buildFormat.AppendFormat("User : {0} \n", user).AppendLine(); buildFormat.AppendFormat("Message : \n {0} \n", message).AppendLine(); buildFormat.AppendLine("-------------------------"); return(buildFormat.ToString()); }
private void Log(string user, string message, Exception ex, Common.LogLevel logLevel) { //string LogFile = AppDomain.CurrentDomain.BaseDirectory + string.Format(@"\Log\{0}log.txt", DateTime.Today.ToString("yyyy_MM_dd_")); string LogFile = logPathFile + string.Format(@"\{0}log.txt", DateTime.Today.ToString("yyyy_MM_dd_")); if (!System.IO.File.Exists(LogFile)) { System.IO.FileStream ficheiro = System.IO.File.Create(LogFile); ficheiro.Close(); } using (System.IO.StreamWriter ficheiro = System.IO.File.AppendText(LogFile)) { ficheiro.WriteLine(FormatFile(user, message, ex, logLevel)); } }
private void Log(string user, string message, Common.LogLevel logLevel) { string LogFile = logPathFile + string.Format(@"\{0}log.txt", DateTime.Today.ToString("yyyy_MM_dd_")); if (!System.IO.File.Exists(LogFile)) { System.IO.FileStream ficheiro = System.IO.File.Create(LogFile); ficheiro.Close(); } using (System.IO.StreamWriter ficheiro = System.IO.File.AppendText(LogFile)) { ficheiro.WriteLine(FormatFile(user, message, logLevel)); } }
private string FormatFile(object logContext, string user, string message, Exception ex, Common.LogLevel logLevel) { buildFormat = new StringBuilder(); buildFormat.AppendFormat("Date : {0} \n", DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss")).AppendLine(); buildFormat.AppendFormat("Logtype : {0} \n", logLevel.ToString()).AppendLine(); buildFormat.AppendFormat("User : {0} ", user).AppendLine(); buildFormat.AppendFormat("Message : {0}", message).AppendLine(); buildFormat.AppendFormat("ValueObject : \n {0} \n", Common.Helpers.BuildStringLog(logContext)).AppendLine(); if (ex != null) { buildFormat.AppendFormat("Exception : \n {0} \n ", ex.ToString()); } buildFormat.AppendLine("--------------------------"); return(buildFormat.ToString()); }
public Task LogAsync(Common.LogLevel level, string data) { InternalLogger.Log(GetLogLevel(level), DefaultClientLogEvent, data, null, (str, ex) => str); return(Task.FromResult <object>(null)); }
public void Log(Common.LogLevel level, string data) { InternalLogger.Log(GetLogLevel(level), DefaultClientLogEvent, data, null, (str, ex) => str); }