.net核心应用程序启动时如何停止登录控制台?

时间:2019-12-08 18:25:44

标签: logging .net-core

我的系统配置发生了变化。 每次我启动dotnet应用程序时,它都会向控制台发送大量日志信息。 谁知道这是什么,以及如何禁用这种跟踪?

它看起来像是来自fuslogvw的日志,但是我检查了它并将其禁用。

起始日志如下:

> dotnet My.dll
Tracing enabled @ Sun Dec  8 18:09:22 2019 GMT
--- Invoked dotnet [version: 3.0.0, commit hash: 7d57652f33493fa022125b7f63aad0d70c52d810] main = {
dotnet
My.dll
}
Reading fx resolver directory=[C:\Program Files\dotnet\host\fxr]
Considering fxr version=[2.1.13]...
Considering fxr version=[3.0.0]...
Detected latest fxr version=[C:\Program Files\dotnet\host\fxr\3.0.0]...
Resolved fxr [C:\Program Files\dotnet\host\fxr\3.0.0\hostfxr.dll]...
Loaded library from C:\Program Files\dotnet\host\fxr\3.0.0\hostfxr.dll
Invoking fx resolver [C:\Program Files\dotnet\host\fxr\3.0.0\hostfxr.dll] v2
Host path: [C:\Program Files\dotnet\dotnet.exe]
and so on...

更新: 我只用一行代码创建了.net核心默认“ Hello World”应用

Console.WriteLine("Hello World!");

StartupLoggingDemo.deps.json

{
    "runtimeTarget": {
        "name": ".NETCoreApp,Version=v2.1",
        "signature": "da39a3ee5e6b4b0d3255bfef95601890afd80709"
    },
    "compilationOptions": {},
    "targets": {
        ".NETCoreApp,Version=v2.1": {
            "StartupLoggingDemo/1.0.0": {
                "runtime": {
                    "StartupLoggingDemo.dll": {}
                }
            }
        }
    },
    "libraries": {
        "StartupLoggingDemo/1.0.0": {
          "type": "project",
          "serviceable": false,
          "sha512": ""
        }
    }
}

StartupLoggingDemo.runtimeconfig.dev.json

{
    "runtimeOptions": {
        "additionalProbingPaths": [
            "C:\\Users\\andre\\.dotnet\\store\\|arch|\\|tfm|",
            "C:\\Users\\andre\\.nuget\\packages",
            "C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder"
        ]
    }
}

StartupLoggingDemo.runtimeconfig.json

{
    "runtimeOptions": {
        "tfm": "netcoreapp2.1",
        "framework": {
            "name": "Microsoft.NETCore.App",
            "version": "2.1.0"
        }
    }
}

startup log output screenshot ...

enter image description here

我在[{https://github.com/dotnet/runtime/blob/4f9ae42d861fcb4be2fcd5d3d55d5f227d30e723/src/installer/corehost/cli/hostpolicy/breadcrumbs.cpp]]中找到了文本“面包屑将使用后台线程编写”,但还不知道如何关闭跟踪。

1 个答案:

答案 0 :(得分:0)

我从@Vitek Karas MSFT得到了答案。

通过设置COREHOST_TRACE = 1(或任何非0)来打开跟踪。因此,请确保您是在未设置此属性的环境中运行该应用的。 (没有其他方法可以启用它,只有环境变量可用)。 模式的详细信息可以在这里找到:https://github.com/dotnet/runtime/blob/4f9ae42d861fcb4be2fcd5d3d55d5f227d30e723/docs/design/features/host-tracing.md

相关问题