如何在不appsetting.json的情况下配置日志记录?
我正在研究.NET Framework 4.7.2 Web API,该API没有AppSetting.json。 我想知道我应该在哪里为Microsoft.extension.logging配置以下设置?
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
并将其绑定到启动时的loggerfilteroption?
下面似乎不起作用:
LoggerFilterOptions options = new LoggerFilterOptions();
var config = UnityConfig.Container.Resolve<IConfiguration>();
config.GetSection("Logging").Bind(options);
我想控制minLoglevel
和规则
(loggerfilteroption)通过web.config,可以实现吗?
I am working on .net framework 4.7.2 web API which doesn't have appsetting.json.
I wonder where should I configure the below setting for Microsoft.Extension.Logging?
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
and Bind it to LoggerFilterOption on Startup?
Below seems not to work:
LoggerFilterOptions options = new LoggerFilterOptions();
var config = UnityConfig.Container.Resolve<IConfiguration>();
config.GetSection("Logging").Bind(options);
I want to control MinLogLevel
and Rules
(LoggerFilterOption)through the web.config, Can that be achieved?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论