本文整理汇总了C#中LogEvent.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# LogEvent.ToString方法的具体用法?C# LogEvent.ToString怎么用?C# LogEvent.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LogEvent
的用法示例。
在下文中一共展示了LogEvent.ToString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Write
/// <summary>
/// Called when any message is written to the log.
/// </summary>
/// <param name="log">The log.</param>
/// <param name="message">The message.</param>
/// <param name="logEvent">The log event.</param>
/// <param name="extraData">The extra data.</param>
protected override void Write(ILog log, string message, LogEvent logEvent, object extraData)
{
string consoleMessage = string.Format("{0} => [{1}] {2}", DateTime.Now.ToString("hh:mm:ss:fff"),
logEvent.ToString().ToUpper(), message);
#if NETFX_CORE
System.Diagnostics.Debug.WriteLine(consoleMessage);
#elif WINDOWS_PHONE
System.Diagnostics.Debug.WriteLine(consoleMessage);
#elif SL4 || SL5
if (InitializeConsole())
{
_dispatcher.BeginInvoke(() => _console.InvokeSelf(consoleMessage));
}
#elif NET
switch (logEvent)
{
case LogEvent.Debug:
System.Diagnostics.Trace.WriteLine(consoleMessage);
break;
case LogEvent.Info:
System.Diagnostics.Trace.TraceInformation(consoleMessage);
break;
case LogEvent.Warning:
System.Diagnostics.Trace.TraceWarning(consoleMessage);
break;
case LogEvent.Error:
System.Diagnostics.Trace.TraceError(consoleMessage);
break;
}
#endif
}
示例2: Write
protected override void Write(ILog log, string message, LogEvent logEvent, object extraData, DateTime time)
{
_textBox.Dispatcher.Invoke(new Action(() =>
{
_textBox.AppendText(string.Format("{0} [{1}] {2}", time.ToString("hh:mm:ss.fff"), logEvent.ToString().ToUpper(), message));
_textBox.AppendText(Environment.NewLine);
_textBox.ScrollToEnd();
}));
}
示例3: Write
/// <summary>
/// Called when any message is written to the log.
/// </summary>
/// <param name="log">The log.</param>
/// <param name="message">The message.</param>
/// <param name="logEvent">The log event.</param>
/// <param name="extraData">The additional data.</param>
protected override void Write(ILog log, string message, LogEvent logEvent, object extraData)
{
string consoleMessage = string.Format("{0} => [{1}] {2}", DateTime.Now.ToString("hh:mm:ss:fff"),
logEvent.ToString().ToUpper(), message);
#if NETFX_CORE
System.Diagnostics.Debug.WriteLine(consoleMessage);
#else
Console.WriteLine(consoleMessage);
#endif
}
示例4: FormatLogEvent
/// <summary>
/// Formats the log event to a message which can be written to a log persistence storage.
/// </summary>
/// <param name="log">The log.</param>
/// <param name="message">The message.</param>
/// <param name="logEvent">The log event.</param>
/// <param name="extraData">The extra data.</param>
/// <returns>The formatted log event.</returns>
protected virtual string FormatLogEvent(ILog log, string message, LogEvent logEvent, object extraData)
{
string logMessage = string.Format("{0} => [{1}] {2}", DateTime.Now.ToString("hh:mm:ss:fff"), logEvent.ToString().ToUpper(), message);
return logMessage;
}