Search code examples
iisopenrasta

Logging of OpenRasta exceptions in IIS


How can I enable logging of any exceptions that occur in my handlers, or codecs etc. in IIS?

When googling for that, I found a couple of different ways on how to setup tracing. One of those actually worked, but the trace file (xml) is not very user-friendly. I'd like to have something like a standard text log file that I can view and manipulate using standard tools.


Solution

  • OpenRasta uses TraceSources to log requests, so you can use any implementation of log files for tracesources by providing the right configuration in your web.config.

       <system.diagnostics> 
        <sources> 
         <source name="openrasta" switchName="OpenRasta"> 
           <listeners> 
             <add name="ErrorLog" /> 
           </listeners> 
         </source> 
       </sources> 
       <switches> 
         <!--<add name="OpenRasta" value="Warning,Error"/>--> 
         <add name="OpenRasta" value="All"/> 
       </switches> 
       <sharedListeners>
    
         <add name="ErrorLog" 
              type="System.Diagnostics.TextWriterTraceListener" 
              initializeData="c:\myListener.log" /> 
       </sharedListeners> 
     </system.diagnostics> 
    

    I'm not sure however what you mean by standard text log files. Standard log files use standard logs that IIS generates itself already, this part of your logging does not change and is configured the usual way in IIS.