Changing the log level programmatically in log4net?

后端 未结 4 852
眼角桃花
眼角桃花 2020-12-14 09:51

Is there a way to set the log level in log4net programmatically? I\'d assumed that there would be a property that would let you do this, but I can\'t seem to find one.

4条回答
  •  春和景丽
    2020-12-14 10:07

    This is a follow up to your comment on Mitch's answer.

    While you may be able to set the levels programmaticaly, why not just set the log levels to debug? That way your user will not have to worry about setting the log levels to debug, which, trust me, will never be on when you need it.

    Then when an error occurs, just have the user send you the full log file and use a log viewer like Apache Chainsaw to selectively view only the levels you want to see.

    Another solution is to log the different levels to separate files. That way you can have the user send you only the levels that you want to see.

提交回复
热议问题