1

Inside an MVC - application I need to write into the IIS-Log. I do this by calling "AppendToLog()" from the HttpResponse:

public static void IIsLog(this HttpResponseBase response, string message, params object [] parameters)
        {
            if (response == null) return;
            response.AppendToLog(string.Format(message, parameters));
        }

Now I usually use log4net to log into logfiles instead, so it would be perfect to use an appender that does exactly the same like my custom code above.

I wasn't able to find any appender on the Apache-Documentation that fits my needs.

Is there any appender that fits my needs?

Ole Albers
  • 8,715
  • 10
  • 73
  • 166
  • You can simply create your own log appender by deriving from `AppenderSkeleton` and overriding `Append(LoggingEvent loggingEvent)`. Also to get access to the current response object, you can use `System.Web.HttpContext.Current.Response`. Make sure `Currnet` and `Response` are not null before trying to `Write`. – Reza Aghaei Nov 03 '16 at 00:06

0 Answers0