I try to find a way to set isdebugenabled false or true in configuration file,
so I can turn it on or off whenever I need. Thanks !
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Using a really simple logging setup
And an equally simple code sample
When
minLevelis set to Debug or Trace, bothlogger.Debugstatements will write to the log. If you raiseminLevelto a higher level (Info, Warn, Off) neither statement will be written to the log.logger.DebugchecksIsDebugEnabled(which is inferred from the log level).You can certainly get a performance increase (in cases where you are going to be logging calculated values and not just strings) by checking
IsDebugEnabled, and changingminLevelfor the logger is the way to toggle this.