Abdel Raoof Olakara
Abdel Raoof Olakara

Reputation: 19353

Enable/Disable Enterprise Library logging on production

On my production, I don't want to have log entry with severity Verbose (or Debug). I need only the info, error etc. What is the right method to enable and disable logging (the debug entries)?

I did some research and one possibility is to use Custom Filter class to enable and disable all logs with severity "verbose". But When deploying application on production, what is the right way to enable and disable?

Upvotes: 4

Views: 10611

Answers (3)

Randy Levy
Randy Levy

Reputation: 22655

You don't have to get in to custom filters. Assuming you have one category defined then you just need to set the Severity or SourceLevel that you want to log. It sounds like you want to set the SourceLevel to Information which "allows Critical, Error, Warning, and Information events through".

In config this would look something like:

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

In terms of best practices there is no one right way. Usually you would probably enable the logging of as little information as required to properly support the application. This will depend on the type of logging you've placed in your application. For most applications this would probably be Information or Warning. However, other factors could influence this including current application stability, operational requirements etc.

Upvotes: 5

frennky
frennky

Reputation: 13934

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

Upvotes: 0

baldy
baldy

Reputation: 5541

You can set your logging level in your config file, that way, should you need it in production for whatever reason, you can switch it on at any time.

Upvotes: 3

Related Questions