5

In my application, I've got the following logging strategy/appenders:

  • DebugAppender: If the root level is DEBUG, write every message that matches DEBUG to the default trace listener output
  • ConsoleAppender: If the application mode (global context property) is 'console', write every message above WARN to the console ouput
  • EventLogAppender: If the application mode (global context property) is 'service', write every message above ERRROR to the console output
  • RollingFileAppender: Write every message above INFO to a rolling flat file

This works very well throughout the whole application, until the very first line I'm starting the OWIN web host using the IAppBuilder interface. As soon as I invoke WebApp.Start, I noticed the following behavior:

  • Debug messages (ILogger.Debug) are getting written to the console output
  • Debug messages (ILogger.Debug) are getting written twice to the VS debug output

Upon further investigation, I figured out that OWIN silently attached an instance of System.Diagnostics.DefaultTraceListener and System.Diagnostics.TextWriterTraceListener to the default trace/debug ouput, which may be the root of the problem. However, declaring the DefaultTraceListener in app.config explicitly didn't help.

Is there any way I can configure OWIN to be less... sneaky?

tckmn
  • 57,719
  • 27
  • 114
  • 156
xvdiff
  • 2,179
  • 2
  • 24
  • 47
  • which is a pity because it seems a well thought out issue. I would of edited it rather than downvote but hey...Also I can't help. – Liam Aug 06 '14 at 08:53
  • 6
    @xvdiff - this is a professional place. Swearing is not acceptable. – ChrisF Aug 06 '14 at 08:54
  • 1
    "Please note that expletives are not allowed." ~ the [Help Center](http://stackoverflow.com/help/behavior) – tckmn Aug 06 '14 at 08:54
  • Now you stuck in a loop arguing over the title...Seriously, next time just don't swear – Liam Aug 06 '14 at 08:54
  • @Doorknob Oh, it's in the guidelines. Well then. – xvdiff Aug 06 '14 at 08:54
  • @Liam Agreed. But now I have plenty of time arguing because by experience, no one is interested to answer a -5 question. ;) – xvdiff Aug 06 '14 at 08:59

1 Answers1

4

You can remove the listener in startup code, eg:

Trace.Listeners.Remove("HostingTraceListener");

(Name from source code)

stuartd
  • 70,509
  • 14
  • 132
  • 163