public static void Log(LoggingSeverity severity, string message) { string severityPrefix = string.Format("[{0}]", severity.ToString().ToUpper()); SetConsoleColor(severity); Console.WriteLine(string.Format("[{0}]{1} : {2}", DateTime.Now.ToString(), severityPrefix, message)); }
/// <summary> /// Write log to log file. /// </summary> /// <param name="message">The log message which need be logged.</param> /// <param name="severity">The error severity.</param> /// <param name="requestId">The reqeust id.</param> /// <remarks>The title property of <see cref="LogEntry" /> represents the request id.</remarks> private void WriteLog(string message, LoggingSeverity severity, Guid?requestId = null) { if (DoesNeedLogging(severity)) { LogEntry logEntry = new LogEntry() { TimeStamp = DateTime.UtcNow, Message = new StringBuilder(severity.ToString()).Append(ASCII.SPACE).Append(message).ToString(), }; logEntry.Title = String.Empty; logEntry.Categories.Add(LoggerCategory); EnterpriseLibraryContainer.Current.GetInstance <LogWriter>().Write(logEntry); } }
public void LogMessage(LoggingSeverity severity, string message) { System.Diagnostics.Debug.WriteLine(severity.ToString() + " : " + message); }