After installing NLog and NLog.config using NuGet package manager I am unable to edit NLog.config, it shows lock icon on it. How to unlock it?
3 Answers
For newer projects the NLog.Config package is not recommended.
From: https://www.nuget.org/packages/NLog.config
Note: Unfortunately this package won't work well when using
<PackageReference>
Advised to:
- download manually: https://raw.githubusercontent.com/NLog/NLog/dev/src/NuGet/NLog.Config/content/NLog.config
- set "Copy To Output Directory" to "Copy if newer"

- 33,915
- 22
- 119
- 174
I had the same problem - the NuGet package for Nlog config was installed in a different location than the root project directory, like for example C:\Users\User\.nuget\packages\nlog.config\4.7.7\contentFiles\any\any\NLog.config
instead of I:\workspaceVS\net50\ConsoleCoreApp1
.
I managed to solved the problem by copying manually the file Nlog.config into the project's root directory and then reference it in my .csproj file in the following way :
<Project Sdk="Microsoft.NET.Sdk">
...
<ItemGroup>
<None Update="NLog.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="NLog.xsd">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
...
<ItemGroup>
</Project>
instead of :
<Project Sdk="Microsoft.NET.Sdk">
...
<ItemGroup>
<None Update="C:\Users\User\.nuget\packages\nlog.config\4.7.7\contentFiles\any\any\NLog.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="C:\Users\User\.nuget\packages\nlog.schema\4.7.7\contentFiles\any\any\NLog.xsd">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
...
<ItemGroup>
</Project>
And now, when I release it, it shows directly in the output directory :
.(I:\workspaceVS\net50\ConsoleCoreApp1\bin\Release\net5.0\win-x86)
├── ...
└── Nlog.config # Holds the configuration for Nlog
-
It worked great, only thing I also had to manually copy NLog.xsd also into the root of the project. Thanks for your solution. – JaisG May 06 '22 at 10:45
You can find the NLog.config
file in {Project Folder}\bin\Debug\net5.0\
. You can open and edit it as you like with Notepad or Visual Studio.

- 1,829
- 1
- 10
- 24

- 9
- 2
-
This comment does not answer the actual question. The NLog.config file is locked for editing. How to unlock? – Diana Mar 23 '22 at 17:46