问题
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:
- 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.
- 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