Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# Logging. What should I use? [closed]

I'm looking at switching to a new unified logging solution for use in our new line of products and I wanted to see what some of the people on Stack Overflow thought. We will need logging for a variety of applicatons: ASP .net, windows services, web services, wpf apps etc. We are a windows shop only.

Some of our requirements for a logging solution include:

1) Log file management

- Ability to split files up over a certain size
- Ability to auto archive/delete after certain period of time

2) Ability to send emails on certain types of messages logged (errors for example)

3) Ability to write messages to the windows event log

- We need to be able to specify where it's being written in the event log. 
  It would also be nice if it would automatically create the event log source if it does exist.

I've started looking at nLog, windows trace and log4net. I'm not limited to these 3 only it's just a few that came up a lot when searching.

like image 715
Cole W Avatar asked Jan 12 '11 16:01

Cole W


4 Answers

log4net is always a good choice.

http://logging.apache.org/log4net/

like image 155
RQDQ Avatar answered Nov 08 '22 01:11

RQDQ


Use .NET common logging. You can choose later a specific provider (NLog, CLog, log4net...), or even create custom ones.

like image 41
HuBeZa Avatar answered Nov 08 '22 02:11

HuBeZa


And just another one: NLog.

  • Files – single file or multiple, with automatic file naming and archival
  • Event Log – local or remote Database – store your logs in databases supported
  • by .NET Network – using TCP, UDP, SOAP, MSMQ protocols
  • Command-line console – including color coding of messages
  • E-mail – you can receive emails whenever application errors occur
  • ASP.NET trace
  • and many more
like image 9
Jorge Córdoba Avatar answered Nov 08 '22 01:11

Jorge Córdoba


You can take a look at Enterprise Library, they have an application block for logging which is extensible

http://entlib.codeplex.com/

http://entlib.codeplex.com/releases/view/46741

you can download the dev guide pdf, they have a section on logging (Chapter 4)

like image 3
pdiddy Avatar answered Nov 08 '22 01:11

pdiddy