gpt4 book ai didi

LogDebug to Debug Console in VS Studio Code(在VS Studio代码中将LogDebug记录到调试控制台)

转载 作者:bug小助手 更新时间:2023-10-28 11:48:53 27 4
gpt4 key购买 nike



I cannot seem to log debug statements to the "Debug Console" in VS Code using dotnet core. I have this statement in my Startup.cs:

在使用DotNet core的VS代码中,我似乎无法将调试语句记录到“调试控制台”中。我的Startup.cs中有这样一条声明:


    public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILogger<Startup> logger)
{
_logger = logger;
...
}

When I print this statement from

当我从


_logger.LogInformation("Testing LogInformation");

I get output in the Debug Console, but when I run this statement:

我在调试控制台中得到输出,但当我运行以下语句时:


_logger.LogDebug("Testing LogDebug");

nothing shows. I would like to do a lot of debug statements which don't carry over to production, unless I configure it to run debug statements. It seems like this would be a configuration setting. I read this post but it does not make sense to me. I seems very intuitive that the LogDebug would show a statement in the Debug Console, and if the challenge, as a link in the post states, is that "If the default was Debug or Verbose then a typical request would have hundreds of log messages flowing through, and that would probably make the log output unusable in most cases.", that challenge should be dealt with in a different way, like being able to filter the component for which debug statements are shown.

什么都没有显示出来。我想做很多调试语句,除非我将其配置为运行调试语句,否则这些语句不会应用到生产环境中。这似乎是一种配置设置。我读了这篇文章,但它对我来说没有意义。我似乎非常直观地认为,LogDebug将在调试控制台中显示一条语句,如果挑战如POST中的链接所述,是“如果缺省设置为Debug或Verbose,则一个典型的请求将有数百条日志消息流经,这可能会使日志输出在大多数情况下不可用。”,应该以不同的方式处理该挑战,如能够过滤显示调试语句的组件。


Am I missing a configuration option? Are others using LogInformation?

我是否遗漏了一个配置选项?其他人是否在使用LogInformation?


更多回答
优秀答案推荐

You can configure this behavior using the file appsettings.Development.json which is located in the root directory of your appplication. In section "Logging" you find a subsection "LogLevel" with attribute "Default" which is set to "Information" by default. If you change this to "Debug", you will also see the output of LogDebug. For more information, see Logging in .NET Core and ASP.NET Core.

您可以使用位于应用程序根目录中的appsettings.Development.json文件来配置此行为。在“日志记录”一节中,您可以找到一个子部分“LogLevel”,其属性为“Default”,该属性在默认情况下设置为“Information”。如果将其更改为“Debug”,您还将看到LogDebug的输出。有关更多信息,请参见登录.NET Core和ASP.NET Core。


更多回答

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com