I need to have the same code logging to two different places in two different contexts. This applies to everything logged – information, warnings, errors – so that I get two separate traces for the two contexts.
I’m inexperienced using entlib, but know it has some functionality for distributing entries to multiple sources.
The code initiating the logging knows which context it is in. Hence, I’m thinking it might be possible to “tag” the LogEntry with some information and then have the LogWriter facade decide where to send entries based on this. Can I do that with just configuration? If not, what do I need to extend/modify in entlib?
Actually it wasn’t too hard to find out.
The solution is to
– have the code create logentries in 2 different categories depending on context
– distribute log entries to two log sources (*)
– configure a filter for each log source so only the relevant category goes through
(*) IMHO, “log source” is an illogical name, but this is the term used by EntLib for an object providing the actual logging implmentation. To my mind, “log destination” or “log provider” would be a far better term. A “log source” would be “the source of the logged information”.