views:

30

answers:

1

Dear ladies and sirs.

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.

A: 

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...

Stefan Egli
What a bummer...
mark