What is the best way to write minimal error logs in an ASP.NET 2.0 web page or web service? For my purposes it'd be best if this was vanilla, and the implementation would work through IIS's virtual directories. I'm currently using the standard TextWriterTraceListener, but it doesn't seem to write to the virtual directory.
FYI - the TextWriterTraceListener's configuration follows:
<system.diagnostics>
<trace autoflush="true">
<listeners>
<add name="myListener" type="System.Diagnostics.TextWriterTraceListener" initializeData=".\VirtualDirectory\SomeLog.log" />
</listeners>
</trace>
</system.diagnostics>
I appreciate your help!
You could try log4net framework. It is very powerfull open-source .NET logging framework. Take a look at Log4net web site
You should really look at log4net. See this question
It might seem like more than you need right now, but once you have it as part of your architecture, it will be available and ready whenever you need it.
If you are only looking for logging of exceptions that make it back to the user, try ELMAH:
http://code.google.com/p/elmah/
On the other hand, if you are looking to track the activity in you app, you can certainly try log4net. I prefer nLog myself, you can find it here:
http://www.nlog-project.org/
Both of these are open source.
you can try System.Diagnosis.TraceSource, which built in .NET 2.0
Logging best practices
Another vote here for log4net. I have a complex remoting application hosted in an Windows service, and it has been extremely useful.
log4net is very powerful and also easily configurable. You can do minimum logging all the time, then switch on more verbose logging in multiple increments by changing a configuration setting.
I'd recommend the Microsoft Enterprise Library which contains the Logging Application block. I've been using it for some time and it works well.
http://www.codeplex.com/entlib/Release/ProjectReleases.aspx?ReleaseId=4474
I use it in WebApps to write out to the Virtual Directory. It's fairly granular and you can easily customise it for your own application
This http://www.codeproject.com/KB/architecture/GetLoggingWithEntLib.aspx is a good article about using it