Enabling / disabling registration in the Enterprise Library

In my production, I do not want to have a journal entry with the severity of Verbose (or Debug). I only need information, an error, etc. What is the correct method to enable or disable logging (debugging entries)?

I did some research, and one of the possibilities is to use the Custom Filter class to enable and disable all verbose logs. But when deploying the application in production, what is the right way to enable or disable?

+4
source share
3 answers

You can set the logging level in your configuration file this way, if you need it in production for any reason, you can enable it at any time.

+3
source

You do not need to enter custom filters. Assuming you have one specific category, you just need to install the Severity or SourceLevel that you want to register. It looks like you want to set SourceLevel to Information , which "resolves the Critical, Error, Warning, and Information events."

In configuration, it would look something like this:

 <categorySources> <add switchValue="Information" name="General"> <listeners> <add name="Formatted EventLog TraceListener" /> </listeners> </add> </categorySources> 

From the point of view of best practice, there is not a single right path. Normally, you would probably enable the registration as little information as possible to properly support the application. This will depend on the type of logging you have posted in your application. For most applications, this is likely to be Information or Warning . However, other factors can affect this, including current application stability, operational requirements, etc.

+5
source

You can set different levels in the web.config.release and web.config.debug files. You can read it here .

0
source

Source: https://habr.com/ru/post/1340778/


All Articles