I am trying to implement logging into my OWIN self hosting solution.
My MiddleWare
class is as follows:
public class HostingMiddleware : OwinMiddleware
{
private readonly ILogger _logger;
public HostingMiddleware(OwinMiddleware next, IAppBuilder builder)
: base(next)
{
_logger = builder.CreateLogger<HostingMiddleware>();
}
public override Task Invoke(IOwinContext context)
{
_logger.WriteVerbose(string.Format("{0} {1}: {2}"));
context.Response.Headers.Add("Content-Type", new[]
{
"text/plain"
});
return Invoke(context);
}
}
I then use this in my Startup
class.
public class Startup
{
public void Configuration(IAppBuilder builder)
{
// Initialize the configuration for Web API self-host.
HttpConfiguration config = new HttpConfiguration();
// Map the default Web API HTTP Route
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
// Use Web API
builder.UseWebApi(config);
builder.Use<HostingMiddleware>(builder);
}
}
When I remove builder.Use<HostingMiddleware>(builder);
I can make a HTTP request and get a response, however when I implement my Middleware
class I get:
No WebSocket support detected, Windows 8 or later is required.
From there forward, the logging doesn't work as it should do. Surely there is a way to get logging to work on a Windows 7 environment otherwise the functionality is rendered pretty useless? Any ideas on what I need to do?
Thanks in advance.