Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Minimizing log statements in production

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?

like image 782
user2181948 Avatar asked Nov 08 '22 22:11

user2181948


1 Answers

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:

  • Managing complex Web.Config files between deployment environments
  • How to select different app.config for several build configurations
  • How to conditionally deploy an app.config based on build configuration?
like image 140
FortyTwo Avatar answered Nov 15 '22 11:11

FortyTwo