IsLoggingEnabled() 可以在运行时更改吗?
我正在封装 EntLib 5 日志记录应用程序块。我在文档中看到,每次您想要记录时,都应该查看“IsLoggingEnabled()”。事实上,它是一个方法而不是一个属性,告诉我这是一个需要一些时间才能完成的操作,但是......我可以将该值缓存在局部变量中并检查是否可以基于它进行记录?
干杯。
I'm encapsulating the EntLib 5 logging application block. I've seen in the documentation that every time that you want to log, you should give a look to "IsLoggingEnabled()". The fact that it's a method and not a property, tell me that is an operation that takes some time to be done, but... could I cache that value in a local variable and check if it's possible to log or not based on it?
Cheers.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您无法通过代码更改日志记录设置,如 企业库文档。但你也可以在那里读到:
也就是说,虽然您无法以编程方式启用/禁用日志记录,但如果手动编辑配置,它可以在运行时更改。
因此,这就是为什么您每次都需要访问
IsLoggingEnabled()
操作,并且缓存它的值并不是一个好主意。You can not, through code, change the Logging settings, as said at the Enterprise Library Document. But there you can also read that:
That is, while you can't enable/disable programatically the logging, it can change at run time if configuration edited manually.
So, that is why you'll need to access the
IsLoggingEnabled()
operation every time, and it's not a good idea to cache it's value.