关闭ServiceStack日志记录

本文关键字:记录 日志 ServiceStack 关闭 | 更新日期: 2023-09-27 18:30:07

ServiceStack的内部日志记录不是我想要的。我们如何禁用内部日志记录,或者至少抑制它,使其不会阻塞日志?

关闭ServiceStack日志记录

配置LogManager时,只需将其设置为NullLogFactory 的实例

LogManager.LogFactory = new NullLogFactory();

ServiceStack版本5>

SetConfig(new HostConfig {
            DefaultRedirectPath = "/metadata",
            DefaultContentType = MimeTypes.Json,
            AppendUtf8CharsetOnContentTypes = new HashSet<string> { MimeTypes.Html, MimeTypes.Json },
            DebugMode = false,
            LogFactory = new NullLogFactory(),
            EnableFeatures = Feature.All.Remove(disableFeatures)
)