本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}