是否可以使用环境变量来为基于 log4net 的日志系统指定所需的日志级别?
我们使用 log4net 进行日志记录。我想知道在指定日志级别时是否可以使用环境变量。动机很简单 - 我们的 QA 人员不必编辑配置文件,他们只需设置一次特定的环境变量。 简而言之:
- 我们不想将配置文件中的日志级别设置为某个恒定值,因为相同的构建由不同的团队运行,并且不同的团队有不同的但很少改变的日志记录需求。现在,每次安装后,都必须更改配置文件以满足特定团队的需求。
- 如果有办法避免的话,我不想以编程方式实现逻辑。如果没有,我想我知道该怎么做。
谢谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我必须测试它,但看起来您可以在配置文件中使用环境变量,如下所示:
更新:
这不适用于日志级别。您可以使用环境变量作为文件附加器的文件名,但显然不能用于日志级别......
I would have to test it but it looks like you can use environment variables as follows in your config file:
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...