当前位置: 首页>>代码示例>>C#>>正文


C# LogEvent.ToString方法代码示例

本文整理汇总了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
        }
开发者ID:JaysonJG,项目名称:Catel,代码行数:42,代码来源:DebugLogListener.cs

示例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();
     }));
 }
开发者ID:llenroc,项目名称:Orc.WorkspaceManagement,代码行数:9,代码来源:TextBoxLogListener.cs

示例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
        }
开发者ID:pars87,项目名称:Catel,代码行数:18,代码来源:ConsoleLogListener.cs

示例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;
 }
开发者ID:paytonli2013,项目名称:Catel,代码行数:13,代码来源:BatchLogListenerBase.cs


注:本文中的LogEvent.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。