Asp.Net Core API禁用启动完成消息
作为我的应用程序的一部分,我有一个.Net Core API项目。与大多数情况下,该项目将作为其自己的进程运行,与其他情况不同,我让API在一个线程中以及其他进程中在单个进程中运行。同样对于我的项目,我已经实现了一个定制的日志记录系统来满足我的需求。但是,我遇到了一个小问题。每次我运行程序时,一旦API启动,该消息就会打印到控制台:
As part of my application I have a .Net Core API project. Unlike most cases where this project would run as its own process, I have the API run in a thread, among others, in a single process. Also for my project, I have implemented a custom logging system to suit my needs. However, I have come across a slight problem. Every time I run my program, once the API starts, this message is printed to the console:
Hosting environment: Production
Content root path: C:\Users\Path\To\Code
Now listening on: http://*:8000
Application started. Press Ctrl+C to shut down.
我想禁用此消息,因为不需要它,否则会造成混乱井井有条的控制台日志。我下面有一个屏幕截图,所以您确切地知道我在说什么:
I would like to disable this message as there is no need for it, and it clutters up the otherwise well organized console log. I have a screenshot below so you know exactly what I'm talking about:
我已经禁用了mvc的所有其他日志记录(从 ConfigureServices
中删除了 ILoggerFactory
在 appsettings.json
中登录到无。
I have already disabled all other logging for the mvc (removed ILoggerFactory
from ConfigureServices
and set all logging to "None" in appsettings.json
).
如何禁用/禁止显示此消息?
How do I go about disabling/suppressing this message?
您也可以这样做:
var host = BuildWebHost(args);
host.Start();
host.WaitForShutdown();
这将绕过 Console.WriteLine()
s。