Вопрос

Well, I'm new to .net and I've been searching some loging tools available for c#. I found, TraceListener and Log4Net created by Apache Foundation, have very wide use even in large projects. But what are the main differences between this two? What are the advantages of Log4Net? In what situation I should use Log4Net and where TraceListener?

Including, What are the disadvantages of Log4Net and TraceListener? What are their break points?

Это было полезно?

Решение

The TraceListener is part of the default logging implementation in .NET. While this works just fine to see what your application is doing (very helpful during development), log4net offers much greater flexibility with regards to the logging output. log4net allows you to configure where your logging output should go (for example: to a file, to the event log, etc.) and allows you to finetune what you want to see logged.

For instance, you want much more diagnostic information on development and test environments while you're only interested in warnings and fatal errors on the acceptance and production environments. With log4net, you can simply configure what you want to be logged, and this can be changed at any time after an application has been deployed.

Другие советы

Here is a nice comparison of System.Diagnostics, log4net, nlog,and Enterprise library:

https://github.com/sgryphon/essential-diagnostics/blob/master/docs/Comparison.md

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top