简体   繁体   English

如何降低docfx冗长度?

[英]How to lower docfx verbosity?

We use docfx, it is included as a nuget in one of our csproj files. 我们使用docfx,它作为一个nuget包含在我们的一个csproj文件中。 I didn't personally setup the thing and I have no more information on how it works, but it looks like a simple nuget added to a C# project which then produces the documentation during the project compilation in Visual Studio. 我没有亲自设置这个东西,我没有关于它如何工作的更多信息,但它看起来像一个简单的nuget添加到C#项目,然后在Visual Studio中的项目编译期间生成文档。

Our problem is that the verbosity of build log is always set to verbose (or detailed or how they call it), ie I have like 20 c# projects in solution and since I have no warnings or errors, the build output in the Output window is very short for whole solution, just a few lines per project. 我们的问题是构建日志的详细程度总是设置为详细(或详细或他们如何调用它),即我在解决方案中有20个c#项目,因为我没有警告或错误,“输出”窗口中的构建输出是整个解决方案非常短,每个项目只需几行。 But this one project with docfx always produce A LOT of output during compilation because it writes all verbose messages to Output window (and also to its log.txt file placed in the project's directory). 但是这个带有d​​ocfx的项目在编译期间总是产生很多输出,因为它将所有详细消息写入Output窗口(以及放置在项目目录中的log.txt文件)。

The question is how to get rid of this from the Output window. 问题是如何从“输出”窗口中删除它。 I tried to google it, I found that --logLevel warning parameter on command line can lower the verbosity. 我试着谷歌它,我发现命令行上的--logLevel警告参数可以降低详细程度。 But we don't use any command line, we have the nuget in project. 但是我们不使用任何命令行,我们在项目中有nuget。 And I can see no place where this --logLevel warning can be specified. 而且我看不到可以指定这个--logLevel警告的地方。

(Using the latest nuget "docfx.console" version 2.40.4, the C# project is of type class library. I can see no special settings anywhere. Visual Studio setting for msbuild verbosity is set to minimal both for Output window and log file.) (使用最新的nuget“docfx.console”版本2.40.4,C#项目属于类库。我在任何地方都看不到任何特殊设置。对于输出窗口和日志文件,msbuild verbosity的Visual Studio设置都设置为最小。 )

EDIT: Since my first response, I have discovered a better way to do it at the project level. 编辑:自从我第一次回复以来,我发现了一个更好的方法在项目层面上做到这一点。

If you edit the .csproj file for the DocFx project to include the following property group, you can set the log level on the project. 如果编辑DocFx项目的.csproj文件以包含以下属性组,则可以在项目上设置日志级别。

<PropertyGroup>
  <LogLevel>Warning</LogLevel>
</PropertyGroup>

I got the idea from this comment on this git issue: https://github.com/dotnet/docfx/issues/2595#issuecomment-379947069 我从这个git问题的评论中得到了这个想法: https//github.com/dotnet/docfx/issues/2595#issuecomment-379947069


ORIGINAL RESPONSE: 原始回应:

I have only found one way to do it, but it will be at the global level, and you may have to set it again if you upgrade to a new version. 我只找到了一种方法,但它将在全球范围内,如果你升级到新版本,你可能不得不重新设置它。

You can modify the docfx.console.targets file to change the log level. 您可以修改docfx.console.targets文件以更改日志级别。 On my computer it is found at 在我的电脑上找到它

C:\Users\<username>\.nuget\packages\docfx.console\<version number>\build\docfx.console.targets

This is an XML file with a place you can set the log level to be used. 这是一个XML文件,您可以在其中设置要使用的日志级别。

<Project ...>
  <PropertyGroup>
    ...
    <LogLevel Condition=" '$(LogLevel)' == '' ">Verbose</LogLevel>
    ...
  </PropertyGroup>

I changed "Verbose" to "Warning" and it significantly reduced the log messages that were generated. 我将“详细”更改为“警告”,它显着减少了生成的日志消息。

Hopefully this can help you too! 希望这也可以帮到你!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM