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
3 Answers
Use the built in Trace
mechanism and document the fact.
This way, all they need to do is configure tracing and they can log.
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.
-
1Is it possible to put the configuration for TraceSource in a config file other than app.config file? Thanks Commented Dec 1, 2011 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. Commented Dec 2, 2011 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".