Munish Goyal
Munish Goyal

Reputation: 1409

Best approach to Logging in .NET?

I think it is a standard question, but didn't find any generic one on SO.

Logging being core to debugging and other diagnostics warrants a good modular and scalable approach for enterprise apps. I am sure everyone here would have used such logging module at some time int heir coding careers.

So i would like to know best practices, best free tools/code used for logging in .NET apps.

.. Any other thing i missed or any more helpful points about logging in general, pl add.

Upvotes: 0

Views: 593

Answers (1)

Muhammad Hasan Khan
Muhammad Hasan Khan

Reputation: 35156

Use Enterprise Library for logging your exceptions, errors, traces, e.t.c. It can redirect your log entries to several sinks like Windows Event Log, File, Database, e.t.c.

Your code doesn't have to worry about target format and storage of log entry. You can configure all of that by modifying the config file.

The actual decision of where the logs go depends on the environment, data and its importance. If you want to be able to search and query the logs then DB is the option. If the sys admin uses Windows Event Log for viewing all logs then you can redirect your logs there.

Logging strategy varies from organization to organization and I believe your application shouldn't dictate it instead allow it to be configurable for which Logging Application Block or any other similar logging framework would be best choice.

Upvotes: 1

Related Questions