本文整理汇总了C#中LogCategory类的典型用法代码示例。如果您正苦于以下问题:C# LogCategory类的具体用法?C# LogCategory怎么用?C# LogCategory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LogCategory类属于命名空间,在下文中一共展示了LogCategory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Log
///<summary>
/// Logs the message to the configured loLog4Netgger with the
/// appropriate <see cref="LogCategory"/>
///</summary>
///<param name="message"></param>
///<param name="logCategory"></param>
public void Log(string message, LogCategory logCategory)
{
if (!IsLogging(logCategory)) return;
switch (logCategory)
{
case LogCategory.Fatal:
_log.Fatal(message);
break;
case LogCategory.Exception:
_log.Error(message);
break;
case LogCategory.Debug:
_log.Debug(message);
break;
case LogCategory.Warn:
_log.Warn(message);
break;
case LogCategory.Error:
_log.Error(message);
break;
default:
_log.Info(message);
break;
}
}
示例2: Log
public void Log(LogCategory category, string text, params object[] parameters)
{
if ((EnabledCategories & category) != 0)
{
Stream.WriteLine(text, parameters);
}
}
示例3: LogException
/// <summary>
/// This method is used to Log any message in the Application.
/// </summary>
/// <param name="eventId">Id of the event. Based on which the message will be retrieved from resource file.</param>
/// <param name="ex">Exception object that needs to be logged in.</param>
/// <param name="message">Some extra information / message that user will like to log.</param>
/// <param name="category">A category which will determine where the message will get logged.</param>
/// <param name="severity">Severity of the message. (Information / Warning / Error)</param>
public static void LogException(int eventId, Exception ex, string message, LogCategory category, TraceEventType severity)
{
try
{
var categories = new List<LogCategory> { category };
var extendedInformation = new Dictionary<string, object> { { "Exception", ex } };
if (string.IsNullOrEmpty(message))
{
message = ex.Message + " - Stack Trace : " + ex.StackTrace;
}
else
{
message = message + " - " + ex.Message + " - Stack Trace : " + ex.StackTrace;
if (message.Length > MAX_EVENTLOG_STRING_LENGTH)
message = message.Substring(0, MAX_EVENTLOG_STRING_LENGTH);
}
WriteLogEntry(eventId, message, categories, severity, extendedInformation);
}
catch (Exception)
{
}
}
示例4: LogEntry
/// <summary>
/// Initializes a new instance of the <see cref="LogEntry"/> class by specifying the category and the detailed information to write.
/// </summary>
/// <param name="category">
/// The log category of this instance.
/// </param>
/// <param name="data">
/// The data containing the detailed information to write to log.
/// </param>
public LogEntry(LogCategory category, object data)
{
Id = Guid.NewGuid();
Category = category;
Created = DateTime.Now;
Data = data;
}
示例5: Log
public void Log(string message, LogCategory logCategory)
{
if (!IsLogging(logCategory)) return;
Console.Out.WriteLine("{0} {1} {2} {3} {4}", DateTime.Now.ToShortDateString(),
DateTime.Now.ToShortTimeString(), _contextName,
Enum.GetName(typeof (LogCategory), logCategory), message);
}
示例6: SetTraceLevel
public static void SetTraceLevel(LogCategory category, SourceLevels sourceLevel)
{
var sourceSwitch = new SourceSwitch(string.Format(CultureInfo.InvariantCulture, "MigSharp.{0}.Switch", category))
{
Level = sourceLevel
};
Sources[category].Switch = sourceSwitch;
}
示例7: Log
/// <summary>
/// Writes a log entry via the logger from <see cref="Logger.Current" />.
/// </summary>
/// <param name="msg">The message to write.</param>
/// <param name="category">The category.</param>
/// <param name="prio">The priority.</param>
/// <param name="tag">The optional tag.</param>
/// <returns>Message was written or not.</returns>
public static bool Log(object msg,
LogCategory category = LogCategory.Info, LogPriority prio = LogPriority.None,
string tag = null)
{
return Current.Log(msg: msg,
category: category, prio: prio,
tag: tag);
}
示例8: Log
public static void Log(this IEnumerable<Logging.ILog> logs, LogCategory category, string message)
{
if (null == logs)
return;
foreach (var l in logs)
if(null != l)
l.Log(category, message);
}
示例9: Log
public override void Log(LogCategory category, string message)
{
if (this.Stack.Count == 0)
return;
var ts = this.Stack.Peek();
if(null != ts)
ts.Log(category, message);
}
示例10: Log
public override void Log(LogCategory category, string message)
{
System.Diagnostics.Debug.WriteLine
(
"{0}ms\t{1}",
this.Elapsed.TotalMilliseconds,
message
);
}
示例11: LogEntryAsync
public static void LogEntryAsync(string message, LogSeverity logSeverity, LogCategory logCategory)
{
Task.Factory.StartNew(() => Logger.Write(new LogEntry
{
Title = logCategory.ToString(),
Message = message,
Categories = new List<string> { logCategory.ToString() },
Severity = GetSeverity(logSeverity)
}));
}
示例12: LogAsync
/// <summary>
/// Async operation of <see cref="LoggerBase.Log(object, LogCategory, LogPriority, string)" /> method.
/// </summary>
/// <param name="msg">The message.</param>
/// <param name="category">The category.</param>
/// <param name="prio">The priority.</param>
/// <param name="tag">The tag.</param>
/// <returns>The started task.</returns>
public Task<bool> LogAsync(object msg,
LogCategory category = LogCategory.Info, LogPriority prio = LogPriority.None,
string tag = null)
{
var logMsg = CreateMessage(msg: msg,
category: category, prio: prio,
tag: tag);
return LogAsync(logMsg: logMsg);
}
示例13: LogEntry
public static void LogEntry(string message, LogSeverity logSeverity, LogCategory logCategory)
{
Logger.Write(new LogEntry
{
Title = logCategory.ToString(),
Message = message,
Categories = new List<string> { logCategory.ToString() },
Severity = GetSeverity(logSeverity)
});
}
示例14: Create
public static LogMessage Create(LogCategory logCategory, LogSeverity logSeverity, string description)
{
return new LogMessage
{
Category = logCategory,
Severity = logSeverity,
Description = description,
CreatedBy = "System",
CreatedDate = DateTime.Now
};
}
示例15: Trace
//[Conditional("TRACE")]
public static void Trace(LogCategory category, string message, params object[] args)
{
//Queue.Queue(delegate
//{
ThreadContext.Properties["Category"] = category;
string messageToLog = string.Format(message, args);
ConsoleLog(ConsoleColor.Gray, message, args);
_logger.Logger.Log(typeof(Log), TRACELevelTRACE, messageToLog, null);
//});
}