Maximum number of trace sources in app.config
Is there a maximum number of trace sources for app.config, and by defi开发者_运维技巧nition listeners as well?
Not a documented one. Which is consistent with almost all .NET framework classes, there are no hard-coded limits. You'll eventually run out of a system resource, usually memory or paging file. Or user patience.
I wouldn't say 20 is necessarily too many - it depends on the size of the application. Think of these as virtual log files, for which you can independently control the output. If you want the ability to turn up the volume on some logging without getting a lot of additional logging in production, having separate trace sources (with the associated source switches) is the way to do that. My rule of thumb is having one per major component. The one issue with having 20 is whether you'll be disciplined enough to correctly use them or whether you'll end up using just a few.
精彩评论