I have a C# console application project which uses log4net as the logging library. Throughout the application there are logging statements (log.Debug()
, log.Error()
, etc.), which are printed to the console as the program runs.
What is the best way to change the logging statements in a production environment, to minimize time of execution caused by logging? I would like some of the statements to not print out at all, and for some logging statements to only be printed out during production.
I am thinking of adding new setting in the Web.config
file which determines how the logging changes. However I think I'd also need to override the log.Debug()
and log.Error()
methods to work with the new setting, but am unsure how to do this. Can anyone advise?
There is no setting in the Web.config
file which can tell log4net to do things differently depending on your build.
However, you can have multiple Web.config
files and deploy the one you want depending on the build or deployment environment. The following links might help:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With