Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

All. I am creating some libraries for other teams in my company. They all have different logging mechanisms. I want to provide trace information of what my libraries are doing. What should I to achieve this? Thanks

share|improve this question
This might belong on stack overflow? – smp7d Dec 1 '11 at 17:06
up vote 11 down vote accepted

Use the built in Trace mechanism and document the fact.

This way, all they need to do is configure tracing and they can log.

share|improve this answer
Thanks for the quick reply – user394128 Dec 1 '11 at 16:07

I would actually suggest using the newer TraceSource class, as recommended by the BCL Team during early .NET 2.0 development. This adds some additional bells and whistles like the ability to name sources independently of one another and handle configuration through app.config files.

share|improve this answer
Is it possible to put the configuration for TraceSource in a config file other than app.config file? Thanks – user394128 Dec 1 '11 at 19:47
I would imagine that any of the .NET *.config files (app.config, machine.config, web.config, etc.) would do. Alternatively, you can configure the TraceSource objects entirely via code. As a result, I suppose you could roll your own configuration system backed by a code library to do the work. – Dan Lyons Dec 2 '11 at 18:41

LibLog lets your library dynamically attach to whatever logging framework is in use, without any additional dependencies.

It's often nicer than Trace etc. for a user, as they don't need to set anything additional up: if they're using a particular logging library, LibLog will detect it and everything will "just work".

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.