Asp.Net Core API禁用启动完成消息

编程入门 行业动态 更新时间:2024-10-09 19:18:02
本文介绍了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: *: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。

更多推荐

Asp.Net Core API禁用启动完成消息

本文发布于:2023-11-07 15:32:48,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1566829.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:消息   Net   Asp   API   Core

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!