Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
348 views
in Technique[技术] by (71.8m points)

c# - TraceListener in OWIN Self Hosting

I am using Microsoft.Owin.Hosting to host the following, very simple web app.

Here is the call to start it:

WebApp.Start<PushServerStartup>("http://localhost:8080/events");

Here is the startup class I am using:

public class PushServerStartup
{
    public void Configuration(IAppBuilder app)
    {
        app.MapHubs();
    }
}

I am running this inside a console application that does a lot of other things including routing trace writing to certain files etc. But all of a sudden (when activating the OWIN hosting) I am seeing trace messages written to the console that are normally routed somewhere else.

Obviously there are some trace listeners active in the OWIN hosting framework. How can I switch them off?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I had the same issue, I was self hosting 4 instances in one process and for each request was getting 4 lots of messages traced to console.

I simply removed the TraceListener instance

Trace.Listeners.Remove("HostingTraceListener")

"HostingTraceListener" is defined in the owin source code so I guess could change - http://katanaproject.codeplex.com/SourceControl/latest#src/Microsoft.Owin.Hosting/Engine/HostingEngine.cs

I did this after

WebApp.Start(...

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...