Can IsLoggingEnabled() change at runtime?

541 views Asked by At

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.

1

There are 1 answers

3
Tomas Narros On BEST ANSWER

You can not, through code, change the Logging settings, as said at the Enterprise Library Document. But there you can also read that:

Note:
Run time changes to the configuration of the Logging Application Block are automatically detected after a short period, and the logging stack is updated. However, you cannot modify the logging stack at run time through code. For details of using configuration mechanisms that you can update at run time, see Updating Configuration Settings at Run Time.

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.