public void Configuration(IAppBuilder application) { HttpLoggingOptions options = new HttpLoggingOptions(); options.MaxRequestLength = 64 * 1024; options.MaxResponseLength = 64 * 1024; options.WhatToDo = entry => { Console.WriteLine("\nTracking Id: " + entry.RequestId); Console.WriteLine("REQUEST"); Console.WriteLine("Verb: {0}", entry.Verb); Console.WriteLine("RequestUri: {0}", entry.RequestUri); Console.WriteLine("Request: {0}", entry.Request); Console.WriteLine("RequestLength: {0}", entry.RequestLength); Console.WriteLine("\nRESPONSE"); Console.WriteLine("StatusCode: {0}", entry.StatusCode); Console.WriteLine("ReasonPhrase: {0}", entry.ReasonPhrase); Console.WriteLine("Response: {0}", entry.Response); Console.WriteLine("Content-Length: {0}", entry.ResponseLength); }; application.Use <HttpLoggingMiddleware>(options); application.UseWebApi(_configuration); _configuration.MapHttpAttributeRoutes(); }
public HttpLoggingMiddleware(OwinMiddleware next, HttpLoggingOptions options) : base(next) { if (options == null) { throw new ArgumentNullException("options"); } if (!string.IsNullOrEmpty(options.TrackingHeaderName)) { _trackingHeaderName = options.TrackingHeaderName; } if (options.MaxRequestLength != null) { _maxRequestLength = options.MaxRequestLength.Value; } if (options.MaxResponseLength != null) { _maxResponseLength = options.MaxResponseLength.Value; } if (options.WhatToDo != null) { _whatToDo = options.WhatToDo; } }