How to track down log4net problems

First you have to set this value on the application configuration file: <configuration> <appSettings> <add key=”log4net.Internal.Debug” value=”true”/> </appSettings> </configuration> Then, to determine the file in which you want to save the output you can add the following code in the same .config file: <configuration> … <system.diagnostics> <trace autoflush=”true”> <listeners> <add name=”textWriterTraceListener” type=”System.Diagnostics.TextWriterTraceListener” initializeData=”C:\tmp\log4net.txt” /> </listeners> … Read more

How to get ELMAH to work with ASP.NET MVC [HandleError] attribute?

You can subclass HandleErrorAttribute and override its OnException member (no need to copy) so that it logs the exception with ELMAH and only if the base implementation handles it. The minimal amount of code you need is as follows: using System.Web.Mvc; using Elmah; public class HandleErrorAttribute : System.Web.Mvc.HandleErrorAttribute { public override void OnException(ExceptionContext context) { … Read more

Output log using FtpWebRequest

You can do this using Network Tracing. To set it up, create (or modify, if you already have one) App.config file, so that it looks like this (if you already have the file, you will need to add the settings to it): <?xml version=”1.0″ encoding=”utf-8″ ?> <configuration> <system.diagnostics> <sources> <source name=”System.Net” tracemode=”protocolonly” maxdatasize=”1024″> <listeners> <add … Read more