OutputDebugStringAppender in a web app?

I spent a couple of hours yesterday trying to get log4net to log to an OutputDebugStringAppender with no success.  At first, I thought I had a configuration error in log4net so I added a file appender and that works fine.  It's a Monorail application that uses ActiveRecord for database access.  There's a couple of spots where I wanted to check out the SQL being generated by ActiveRecord (NHibernate).  I did all my set up for log4net and even got it logging to a FileAppender.  But I wanted to log the SQL to an OutputDebugStringAppender.

Here's my logging set up:

   1: <log4net>
   2:     <!-- Define some output appenders -->
   3:     <appender name="logfile" type="log4net.Appender.FileAppender, log4net">
   4:         <file value="log-file.txt" />
   5:         <appendToFile value="true" />
   6:         <layout type="log4net.Layout.PatternLayout">
   7:             <conversionPattern value="%d [%t] %-5p %c - %m%n"/>
   8:         </layout>
   9:     </appender>
  10:     <appender name="ods" type="log4net.Appender.OutputDebugStringAppender, log4net">
  11:         <layout type="log4net.Layout.PatternLayout,log4net">
  12:             <conversionPattern value="%d [%t] %-5p %c - %m%n"/>
  13:         </layout>
  14:     </appender>
  15:     <logger name="NHibernate.SQL">
  16:         <level value="ALL" />
  17:         <appender-ref ref="logfile" />
  18:         <appender-ref ref="ods" />
  19:     </logger>
  20:     <root>
  21:         <!-- priority value can be set to ALL|INFO|WARN|ERROR -->
  22:         <priority value="ALL" />
  23:         <appender-ref ref="ods" />
  24:     </root>
  25: </log4net>

The log-file.txt gets all the logging I want, but I really just wanted to be able to view these statements in DebugView (gives me a bit more control in clearing out past queries, setting filters/highlight colors, etc…)

I'm positive I had something like this working before but I get NOTHING in DebugView.  Anyone have any ideas as to what I'm doing wrong?  Is there a permission issue that makes this not possible?

2 Comments

  • Try replacing with and watching the output window in VS

  • Have you checked the capture settings in DebugView?

    I have run into issues before when I have run DebugView in a terminal session. I think I needed to set the Capture Global Win32 option (or one of the settings!) to view events raised by background services. So if you think the log4net config is o.k check you DebugView settings.

Comments have been disabled for this content.