现在我正在这样做
LogManager.DisableLogging();
但是这需要再次部署我的代码,如何从nlog配置文件中禁用loggin。
答案 0 :(得分:7)
<nlog globalThreshold="Off" />
答案 1 :(得分:0)
这可能会有所帮助 - 在 csproj 文件中,您需要在包含 Condition="'$(Configuration)' == 'Debug'"
的位置添加 NLog.config
示例:
<Project>
...
<ItemGroup>
<Content Include="NLog.config" Condition="'$(Configuration)' == 'Debug'">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
...
</Project>
这样,在发布模式下,它不应该记录任何内容,因为不包含 NLog.config。