views:

1905

answers:

6

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!

+5  A: 

You could try log4net framework. It is very powerfull open-source .NET logging framework. Take a look at Log4net web site

+4  A: 

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.

Geoff
+1  A: 

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

Gordon Carpenter-Thompson
+2  A: 

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.

Dana Holt
+1  A: 

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.

ninj
A: 

there are a lot different logging functionality. each one keeps your time providing some base functionality but there is not anyone to covers 100% of your requirements (I do not say about projects like "Hello world!") . of course better one is self created or third party attached to project as source code because it can be customized as you need. I prefer use this one .net logging

Universal