views:

291

answers:

1

We have many assemblies (class libraries) which our main application uses. I want to route the logs of some assemblies to different destinations, but I have one App.Config file, so how may I achieve this? I'm pretty much sure there is a setting like this in Logging Application Block which I'm unaware of. Also I want to route logs based on their priority (whether they should be logged or not) for each assembly which I'm doing logging.

A: 

I found the solution. What I did is that for each assembly a created a category and a trace listener. And I used the main executable's app.config file and the other assemblies are working fine.

Considering the log level, its already there in Logging Application Block, you can handle that with the SourceLevels property of the Category Sources or the Filter property of the Trace Listeners. The difference between both is in scope.

From patterns & practices's discussion forum:

They're the same, the only difference is in their scope. The SourceLevels property in the Category applies to all trace listeners belonging to it. The Filter property in a trace listener obviously only applies to itself. Filtering is done first on the Category level the on the trace listener. If the Category is more restrictive, then it does not proceed to call the trace listeners. If it allows all types of event, it then pass the log entry to each trace listener and each of them detects if it will log that entry based on its Filter.

hab