据我所知,其他人做了什么来解决 Commons Logging 项目(针对 .NET 和 Java)不支持映射或嵌套诊断上下文这一事实?
执行摘要:
我们选择直接使用实现者日志框架(在我们的例子中为 log4j)。
长答案:
您是否需要一个抽象日志框架来满足您的要求?它们非常适合那些希望与最终所处的主机环境良好配合的库,但如果您正在编写应用程序,则在许多情况下可以直接使用实现日志记录框架(即通常没有任何理由)为什么日志记录实现者应该在应用程序的生命周期中发生变化)。
我们选择直接使用实现者日志框架(在我们的例子中为 log4j)。 Commons-Logging 在类路径上可用,但它只是为了依赖它的库而存在。在我们的例子中,这是一个简单的选择,因为我工作的公司多年来一直将 log4j 作为强制性标准,并且不太可能改变,但即使这不太明显,它也可以归结为一些成本/收益分析。
- NDC 和其他专业功能给我带来什么好处?
- 必须更改日志记录实现者的可能性有多大?如果必须更改,成本是多少?
有可能:
In our case, if we ever are required to change logging implementors, we'll have some refactoring to do, but with everything in the org.apache.log4j package, that's neither a difficult nor a very risky refactoring1. The log4e Eclipes plugin will happily convert the actual logging statements automatically; the NDC object could be a problem because not all logging frameworks support such a thing. You could consider hiding the NDC.enter() and NDC.leave() methods inside a utility class under your own control, we didn't bother.
1) famous Last Words
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)