I constantly keep seeing ASP.NET developers using log4net for logging and auditing their Web apps. While I have nothing against log4net – it is great stuff I presume though never used it – it is pretty funny to me to get why people do not use built-in ASP.NET 2.0 Health Monitoring. I started to ask – turns out people are just not aware of it…
Our logging story with ASP.NET 1.1 was pretty bad although with small effort one could do very cool things with TraceListener.
I think it was mistake calling it Health Monitoring since folks miss it – no one looks for Health Monitoring but logging or may be auditing.
So here is detailed how-to for ASP.NET 2.0 Auditing and Logging, …ehm …Health Monitoring:
For those who still on ASP.NET 1.1 similar pluggable design can be achieved by implementing Custom TraceListener. Then registering it with web.config. In order to send error message to it one uses standard System.Diagnostics.Trace.WriteLine(message);
Here is custom TraceListener:
public class CustomListener : TextWriterTraceListener
public CustomListener() : base()
public CustomListener(string initData)
public override void Write(string message)
//ACTUAL CODE TO SEND MESSAGES TO SOME STORE, SAY WEB SERVICE
public override void WriteLine(string message)
//ACTUAL CODE TO SEND MESSAGES TO SOME STORE, , SAY WEB SERVICE
and here is web.config configuration:
<trace autoflush=”true” indentsize=”0″>
Ed. – After posting this one I’ve jsut noticed your personal approach to my question here Logging and ASP.NET Health Monitoring.
Mitch, you rock, man!