Is it possible to use environment variable to specify the desired log level for the log4net based logging system?

一个人想着一个人 提交于 2020-01-15 04:13:07

问题


We use log4net for logging. I am wondering if it is possible to use environment variables when specifying the log level. The motivation is simple - our QA folks will not have to edit the config files, they will just set certain environment variable once. In short:

  1. We do not want to set the log level in the config file to some constant value, because the same build is run by different teams and different teams have different, but rarely changing logging needs. Right now, after every installation, one has to change the config file to suit the specific team needs.
  2. I do not want to implement the logic programmatically, if there is a way to avoid it. If not, I think I know how to do it.

Thanks.


回答1:


I would have to test it but it looks like you can use environment variables as follows in your config file:

<root>
   <level value="${LOGLEVEL}" />
   ...
</root>

Update: This does not work for the log level. You can use environment variables for the file name of a file appender but apparently not for the log level...



来源:https://stackoverflow.com/questions/2600147/is-it-possible-to-use-environment-variable-to-specify-the-desired-log-level-for

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!