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


C# ILogger.LogMultiline方法代码示例

本文整理汇总了C#中ILogger.LogMultiline方法的典型用法代码示例。如果您正苦于以下问题:C# ILogger.LogMultiline方法的具体用法?C# ILogger.LogMultiline怎么用?C# ILogger.LogMultiline使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ILogger的用法示例。


在下文中一共展示了ILogger.LogMultiline方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LogRequest

        /// <summary>
        /// Logs the request.
        /// </summary>
        /// <param name="logger">The logger.</param>
        /// <param name="request">The request.</param>
        /// <param name="workerIndex">Index of the worker.</param>
        public static void LogRequest(ILogger logger, HttpListenerRequest request, int workerIndex)
        {
            var log = new StringBuilder();

            log.AppendLine("Ip: " + request.RemoteEndPoint + ". Headers: " + string.Join(",", request.Headers.AllKeys.Select(k => k + "=" + request.Headers[k])));

            var type = request.IsWebSocketRequest ? "Web Socket" : "HTTP " + request.HttpMethod;

            logger.LogMultiline(type + " " + request.Url, LogSeverity.Debug, log);
        }
开发者ID:jscorrea,项目名称:MediaBrowser,代码行数:16,代码来源:LoggerUtils.cs

示例2: LogRequest

        public static void LogRequest(ILogger logger, HttpListenerContext ctx, int workerIndex)
        {
            var log = new StringBuilder();

            log.AppendLine("Url: " + ctx.Request.Url);
            log.AppendLine("Headers: " + string.Join(",", ctx.Request.Headers.AllKeys.Select(k => k + "=" + ctx.Request.Headers[k])));

            var type = ctx.Request.IsWebSocketRequest ? "Web Socket" : "HTTP " + ctx.Request.HttpMethod;

            logger.LogMultiline(type + " request received on worker " + workerIndex + " from " + ctx.Request.RemoteEndPoint, LogSeverity.Debug, log);
        }
开发者ID:RomanDengin,项目名称:MediaBrowser,代码行数:11,代码来源:LoggerUtils.cs

示例3: LogRequest

        /// <summary>
        /// Logs the request.
        /// </summary>
        /// <param name="logger">The logger.</param>
        /// <param name="request">The request.</param>
        /// <param name="workerIndex">Index of the worker.</param>
        public static void LogRequest(ILogger logger, HttpListenerRequest request, int workerIndex)
        {
            var log = new StringBuilder();

            //var headers = string.Join(",", request.Headers.AllKeys.Where(i => !string.Equals(i, "cookie", StringComparison.OrdinalIgnoreCase) && !string.Equals(i, "Referer", StringComparison.OrdinalIgnoreCase)).Select(k => k + "=" + request.Headers[k]));

            //log.AppendLine("Ip: " + request.RemoteEndPoint + ". Headers: " + headers);

            var type = request.IsWebSocketRequest ? "Web Socket" : "HTTP " + request.HttpMethod;

            logger.LogMultiline(type + " " + request.Url, LogSeverity.Debug, log);
        }
开发者ID:Rycius,项目名称:MediaBrowser,代码行数:18,代码来源:LoggerUtils.cs

示例4: LogResponse

        /// <summary>
        /// Logs the response.
        /// </summary>
        /// <param name="logger">The logger.</param>
        /// <param name="statusCode">The status code.</param>
        /// <param name="url">The URL.</param>
        /// <param name="endPoint">The end point.</param>
        /// <param name="duration">The duration.</param>
        public static void LogResponse(ILogger logger, int statusCode, string url, string endPoint, TimeSpan duration)
        {
            var log = new StringBuilder();

            log.AppendLine(string.Format("Url: {0}", url));

            //log.AppendLine("Headers: " + string.Join(",", response.Headers.AllKeys.Select(k => k + "=" + response.Headers[k])));

            var responseTime = string.Format(". Response time: {0} ms.", duration.TotalMilliseconds);

            var msg = "HTTP Response " + statusCode + " to " + endPoint + responseTime;

            logger.LogMultiline(msg, LogSeverity.Debug, log);
        }
开发者ID:bigjohn322,项目名称:MediaBrowser,代码行数:22,代码来源:LoggerUtils.cs

示例5: LogResponse

        /// <summary>
        /// Logs the response.
        /// </summary>
        /// <param name="logger">The logger.</param>
        /// <param name="ctx">The CTX.</param>
        /// <param name="url">The URL.</param>
        /// <param name="endPoint">The end point.</param>
        /// <param name="duration">The duration.</param>
        public static void LogResponse(ILogger logger, HttpListenerContext ctx, string url, IPEndPoint endPoint, TimeSpan duration)
        {
            var statusCode = ctx.Response.StatusCode;

            var log = new StringBuilder();

            log.AppendLine(string.Format("Url: {0}", url));

            log.AppendLine("Headers: " + string.Join(",", ctx.Response.Headers.AllKeys.Select(k => k + "=" + ctx.Response.Headers[k])));

            var responseTime = string.Format(". Response time: {0} ms", duration.TotalMilliseconds);

            var msg = "Response code " + statusCode + " sent to " + endPoint + responseTime;

            logger.LogMultiline(msg, LogSeverity.Debug, log);
        }
开发者ID:RomanDengin,项目名称:MediaBrowser,代码行数:24,代码来源:LoggerUtils.cs


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