Search code examples
c#asp.netloggingevent-log

Logging exceptions in asp.net


In my team there is discussion about web application exception logging, regarding whether we should log to a text file or the event log.

Can anyone please tell me which is the better way of exception logging occuring in the application? Either one of the two I've already mentioned or is there a better option?


Solution

  • Don't reinvent the wheel - use an already existing logging library/tool such as log4net or ELMAH instead of writing your own logging library. Both give you multiple choices for where you log exceptions to, it's up to you which you prefer.

    Two things to consider:

    1 - Where do you log to if you're logging to the database, but the database is unavailable / under heavy load?
    2 - Windows Event Logging is very light-weight and event log forwarding means you can automagically aggregate logs from multiple machines without writing any code.